![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
| "Andy Dingley" <dingbat (AT) codesmiths (DOT) com> wrote in message news:4ff25660-ff45-43d0-afa3-9c914f5192f3 @m74g2000hsh.googlegroups.com. .. On 2 Oct, 17:41, "CJM" <cjmn... (AT) removeme-yahoo (DOT) co.uk> wrote: I've tried various things to achieve this (e.g setting margins to auto) but I'm not having much luck. CSS has two notions of "centring" Block-behaving elements will center if you set their own margins to auto. Inline-behaving elements (and this includes <img> with default CSS settings) will respond to setting text-align on their parent (i.e. the <div>) instead. I'd considered text-align, but I don't want the text part of it centered. So I wrapped the the whole lot in a <span> and set it's margins to auto and it's width to 470px, but that didn't work either. |
#2
| |||
| |||
|
#3
| |||
| |||
|
|
I've tried various things to achieve this (e.g setting margins to auto) but I'm not having much luck. |
#4
| |||
| |||
|
|
"Andy Dingley" <dingbat (AT) codesmiths (DOT) com> wrote in message news:4ff25660-ff45-43d0-afa3-9c914f5192f3 (AT) m74g2000hsh (DOT) googlegroups.com... Block-behaving elements will center if you set their own margins to auto. Inline-behaving elements (and this includes <img> with default CSS settings) will respond to setting text-align on their parent (i.e. the div>) instead. I'd considered text-align, but I don't want the text part of it centered. So I wrapped the the whole lot in a <span> and set it's margins to auto and it's width to 470px, but that didn't work either. |
#5
| |||
| |||
|
|
So I wrapped the the whole lot in a <span> and set it's margins to auto and it's width to 470px, but that didn't work either. |
#6
| |||
| |||
|
| "Andy Dingley" <dingbat (AT) codesmiths (DOT) com> wrote in message news:4ff25660-ff45-43d0-afa3-9c914f5192f3 (AT) m74g2000hsh (DOT) googlegroups.com... On 2 Oct, 17:41, "CJM" <cjmn... (AT) removeme-yahoo (DOT) co.uk> wrote: I've tried various things to achieve this (e.g setting margins to auto) but I'm not having much luck. CSS has two notions of "centring" Block-behaving elements will center if you set their own margins to auto. Inline-behaving elements (and this includes <img> with default CSS settings) will respond to setting text-align on their parent (i.e. the div>) instead. I'd considered text-align, but I don't want the text part of it centered. So I wrapped the the whole lot in a <span> and set it's margins to auto and it's width to 470px, but that didn't work either. |
#7
| |||
| |||
|
|
CJM wrote: I'd considered text-align, but I don't want the text part of it centered. So I wrapped the the whole lot in a <span> and set it's margins to auto and it's width to 470px, but that didn't work either. span class="banner"><img style="display:block;margin:auto;" src="...... |
#8
| |||
| |||
|
|
CJM wrote: So I wrapped the the whole lot in a <span> and set it's margins to auto and it's width to 470px, but that didn't work either. Because a span is in-line and not a block. In-line elements cannot be centered. Centering something that is in-line does not make sense. |
|
If you want an image inside a div to be centered, but not the text inside the div, you may need to place the image and text inside thier own divs. |
#9
| |||
| |||
|
|
Gus Richter wrote: CJM wrote: I'd considered text-align, but I don't want the text part of it centered. So I wrapped the the whole lot in a <span> and set it's margins to auto and it's width to 470px, but that didn't work either. span class="banner"><img style="display:block;margin:auto;" src="...... The <span> is superfluous if its only content is the <img>. |
![]() |
| Thread Tools | |
| Display Modes | |
| |