![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
| http://www.kidsinaction.org.uk/freds/freds.html Most of this is fairly simple to recreate in CSS, but the picture of the candelabra has got me stuck. How do I place that so that it will stay in the right position? |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Alan Silver <alan-silver (AT) nospam (DOT) thanx.invalid> wrote: http://www.kidsinaction.org.uk/freds/freds.html Most of this is fairly simple to recreate in CSS, but the picture of the candelabra has got me stuck. How do I place that so that it will stay in the right position? Various ways to do this, one method: create a single image with transparency outside of the circle, place a span with a class or id in your markup somewhere in the content area, define the image as a background image to this span, give it the dimensions of the image, specify "position:absolute" and left:-[half the width of the image] and top:-[half the height of the image], wrap the content area in a div, specify "position:relative" for this div to make it the containing block for the absolutely positioned span. |
#5
| |||
| |||
|
|
Maybe I didn't make the point clear enough, but the specific problem I was facing with this issue was that the left margin will *not* be sized in pixels, it will be sized in either % or em. To get the left position of the image, you need to take the width of the left margin, then subtract half the width of the image. |
|
Maybe your answer does address this problem, in which case I didn't understand what you were suggesting. If so, please could you post some code so I can see what you meant? |
#6
| |||
| |||
|
|
Alan Silver <alan-silver (AT) nospam (DOT) thanx.invalid> wrote: Maybe I didn't make the point clear enough, but the specific problem I was facing with this issue was that the left margin will *not* be sized in pixels, it will be sized in either % or em. To get the left position of the image, you need to take the width of the left margin, then subtract half the width of the image. Sorry, I've no idea what you're on about. |
|
Maybe your answer does address this problem, in which case I didn't understand what you were suggesting. If so, please could you post some code so I can see what you meant? http://homepage.ntlworld.ie/spartanicus/freds/index.htm I changed it slightly from what I described to get around a Firefox z-index bug that I couldn't be bothered to figure out. |
#7
| |||
| |||
|
|
1) Why did you use a <span> for the candelabra instead of a <div>? I'm not sure it would make any difference in practice, but all the CSS stuff I've seen uses <div> for laying out stuff. |
|
2) Why did you give the <span> a class rather than an ID? Again, I'm not sure it makes a difference |
|
3) I can't work out how you lined up the centre of the image with the edge of the left margin. The margin has a width of 18em, so I would have expected you to set the image's left to 18em, then use the negative margin to shift it left by half the image width. You actually set the image's left to 20em. Where did the extra 2em come from? |
#8
| |||
| |||
|
|
Alan Silver <alan-silver (AT) nospam (DOT) thanx.invalid> wrote: snip |
|
3) I can't work out how you lined up the centre of the image with the edge of the left margin. The margin has a width of 18em, so I would have expected you to set the image's left to 18em, then use the negative margin to shift it left by half the image width. You actually set the image's left to 20em. Where did the extra 2em come from? #sidebar has a 1em padding, this is added to the width of the div under CSS box model rules. |
![]() |
| Thread Tools | |
| Display Modes | |
| |