For the lady/dogs image, I would add position:relative to #head, and then place that image within the head div. I would also use the full image, without the lady’s head being cut off. Give the image position:absolute, and place the image in the top right of the #head div, giving it a negative top and right margin. E.g.
The girls is being cut off because of the overflow:hidden I added to clear the floats. When you need visible overflow you will need to use another clearing method so try this.
Thanks Paul, that works now - although I don’t really understand why?
I’ve never seen :after used before, nor the content:“.” - can you explain what they are doing, or point me in the direction of somewhere I could read up on it?
overflow: hidden is much simpler and is widely used, but you discovered why it isn’t always appropriate—such as when you want content to hang outside the container. (BTW, sorry for not seeing that coming earlier… I should have checked for that.)
No need to apologise, I would have been stuck without the advice so thanks to you, Paul and Ray for all the help!
As a side, although I don’t need to do that anymore, is there a way to place a background image a set distance from the bottom or the right, as opposed to the top or left?
This is the default setting. You can replace “transparent” with a color, such as #ff0000. Inside the brackets you place a path to an image. Instead of scroll you can used fixed. Instead of repeat you can use no-repeat or repeat-y or repeat-x.
0 0 means 0% from the left and 0% from the top. So if you change that to 100% 100%, for example, the image will sit at the bottom right, or if you use 50% 50% the image will be centered (the middle of the top of the image aligns with the middle of the container’s top, and the middle of the side of the image aligns with the middle of the side of the container). You can also use words like top center, or other values like 10px 40%.
So you could place the image near the bottom right corner, but you would not be setting a distance “from” the bottom right corner. If using pixels, you would be setting the distance of the image’s top left corner from the top left corner of the container. If using % (say 90%) you would be placing the point 90% down or along the image 90% down or along the container.
Thanks for the reply Ralph and yes that does make sense - but am I right in saying that it wouldn’t work in a fluid layout, i.e. one where it would always be a fixed distance from the bottom (say 100px).
You can’t place a background image at 100px from the bottom but you could place it at 90% form the top as Ralph suggested. It will work just the same in a fluid layout as a fixed one and will keep at the position you set.
You could add 100px of transparent image to the bottom of the background image itself and then place it at 100% and that would give you the effect of being at 100px from the bottom of that element at all times.
Am I not right in saying though that by using a percentage as a distance, it couldn’t be pixel accurate? I.e. rounding of numbers might cause the position to be a pixel out?
I do like the idea of the transparent gap though - don’t know why I never thought of it myself!
It depends on what element you have it placed in. If the element is a fluid height (as it should be) then 90% of say 1000px height is completely different from 90% of 2000px height. and may be many tens of pixels difference.
You could only be accurate if your element had a fixed height and worked out what percentage would leave you with a 100px gap
Paul, wouldn’t it have been simpler to replace {overflow: hidden;} with {display: table;}? I didn’t test this page, but since there’s a declared width, there’s no worry about shrink-wrapping, and IE6/7 is covered by the width being a hasLayout trigger.
edit: Never mind. I forgot the purpose was to allow for an overflow condition which {display: table;} would not allow. My bad. :head hung in shame: ⇐ where’s a ‘head hung in shame’ icon?
lol - If I remember correctly the element that was overflowing was being placed there absolutely so Firefox would have baulked at the position:relative and display:table anyway.
If the element was overflowing by negative margins then display:table would have been ok so it was a fair suggestion
display table doesn’t hide overflow by default but it will stretch to accommodate an element that is too big and therefore there wouldn’t be any overflow.
I had to run tests to check all those - just to be sure