In one of my pages I discovered te bottom of an image covering text. There are many images in this page and others using exactly the same code. I also have a parallel page with identical text/image content and the some surrounding code. No problems with those.
I’ve looked for the culprit in every single dot , to no avail.
of course, I can solve the problem with <br><br><br> as nothing else works like clear:both.
That one image is broken because …ok well let me explain.
On your .img-container for the broken page, it has a padding-top:66.6%. This refers to 66.6% of the width of the element. Now we need to take 66.6% of that and that will be the height of the img-container will be (and when the text will start appearing). So 820*0.66 (820 is the width of .ad) is roughly 546px. So this means, if the height of the image is taller than 546px, then text will overlap with the image.
Now look at the height of the broken image. How tall is that .
So the broken image, if you will note, is very tall; taller than the rest actually.
You were playing with fire, with this method. Tall images will suffer. Notice that smaller images have more space between the text and the image than images which are slightly taller. Clicking now?
You say that if the img is taller than 546:trouble. But the image is only 407px. And where did you get the 800px for the ad. The image is 400px wide. Here, I guess it is not the width of the image that matters.
820 is in reference to the .ad element
0.66 refers to the 66% top padding. We are multiplying it times 820 because, as I said, padding-top percent values base off of the WIDTH. .
It doesn’t matter what the image width is; you are setting the top padding on the parent container. So the image has NOTHING to do with the issue right now (aside from it being tall )
So, the height of .img-container will only be as tall as 66.6% of the parents width. The parent is .ad. So 0.66*820 (that’s the width of the .ad element) is 546. After 546px, text will overlap (or rather, underlap)
Wait I’m looking at #att3, the taller image. #att4 has no overlap. Did you mean to talk about #att3?
yes it’s the one in the picture you included above.
meanwhile I’ve been messing arounwith the css and it’s utter chaos! I changed from position absolute to static as in the other stylesheet, without really undersrtanding the difference… I manage to sort out the text, but the images (all of them) went walk-abouts to the left.
margins right and left auto did not solve the problem!
We get 30 minutes for lunch. Any more and we have to stay a smidge extra (or use paid time off.)
You said this was a live site so I thought I’d just get it fixed. Besides, who needs 30 minutes to eat a sandwich and a bag of chips? Normally I will listen to a podcast or read articles during lunch anyway.
What about the canapés, the bottle of Bordeaux, the crème brulée, the Camamberts and the Stiltons, not to forget the Port afterwards? You need more than 30 minutes!
You’re making me feel guilty, so I guess I will have to send you one of our standard lunches as above as a means of saying thank you. Mind you, you may ahve to take your annual 5 days leave to munch through it!