html - h2 elements all bunched up on top image on iOS & Firefox -
on site codexr.io noticing while h2 elements work on size browser chrome, seeing ios safari , firefox, of h2s on top of 1 in 1 of main images.
here's html:
<div class="content"> <p><a href="http://codexr.io/collaborative"><img alt="" height="450" src="/sites/default/files/workplace-1245776.jpg" width="800"></a></p> <h2 class="top-area-text">collaborative</h2> </div>
and css:
#top-area .top-area-text, #top-area .region-top-fifth h2, #top-area .region-top-fifth h2 { left: 0; text-align: center; top: 4em; width: 100%; color: white; font-size: 3em; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; text-transform: uppercase; } #top-area .top-area-text { position: absolute; }
is there i'm missing? why chrome working firefox , ios not? malformed?
the problem position: absolute;
without position: relative;
on parent div. don't know why not happening in chrome. perhaps cached? have problem on site in chrome well.
according mozilla absolutely positioned element positioned relative closest positioned ancestor:
the element removed normal document flow; no space created element in page layout. instead, positioned relative closest positioned ancestor if any; otherwise, placed relative initial containing block. final position determined values of top, right, bottom, , left. value creates new stacking context when value of z-index not auto. absolutely positioned boxes can have margins, , not collapse other margins.
adding code in chrome inspector solves problem on end:
#top-area .content { position: relative; }
this replicates issue on site , shows how resolve it:
#top-area .top-area-text, #top-area .region-top-fifth h2, #top-area .region-top-fifth h2 { left: 0; text-align: center; top: 4em; width: 100%; color: white; font-size: 3em; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; text-transform: uppercase; } #top-area .top-area-text { position: absolute; } /* remove code reproduce issue on site. */ #top-area .content { position: relative; }
<div id="top-area"> <div class="content"> <p><a href="http://codexr.io/collaborative"><img alt="" height="450" src="http://codexr.io/sites/default/files/workplace-1245776.jpg" width="800"></a></p> <h2 class="top-area-text">collaborative</h2> </div> <div class="content"> <p><a href="http://codexr.io/collaborative"><img alt="" height="450" src="http://codexr.io/sites/default/files/workplace-1245776.jpg" width="800"></a></p> <h2 class="top-area-text">test</h2> </div> <div class="content"> <p><a href="http://codexr.io/collaborative"><img alt="" height="450" src="http://codexr.io/sites/default/files/workplace-1245776.jpg" width="800"></a></p> <h2 class="top-area-text">test2</h2> </div> </div>
Comments
Post a Comment