javascript - Safari/Chrome overlapping elements that are set with inline-block -
i trying build page display 2 images side side. want these items centered on screen in book format , browser resized, images height changed fill window.
in order using display inline-block text-aligned center achieve affect. works great on ff when open in safari or chrome on resize divs begin overlap. created jsfiddle show example of dom. need pageone , pagetwo divs inline-block because later absolutely position links on top of page images.
what missing?
in order see issue, you'll need open jsfiddle in safari/chrome , make result pane larger default. start browser 1/2 normal width/height. run jsfiddle, enlarge browser , notice how 2 images begin overlap. if open in ff wont overlap.
i able close effect want in browsers using tables:
indeed, tricky because inline-block containers don't resize fit contents contents scale.
though make job harder (read: require javascript) when comes absolutely positioning links atop images, here's alternative approach using background-size: contain.
html:
<div id="issue"> <div id="leftpage" class="page" style="background-image: url(http://placekitten.com/g/304/400);"></div> <div id="rightpage" class="page" style="background-image: url(http://placekitten.com/g/304/400);"></div> </div> css:
html, body { height: 100%; background: #666; } #issue { position: absolute; top: 20px; bottom: 20px; left: 20px; right: 20px; border: 1px solid grey; box-sizing: border-box; background: #eee; } .page { position: absolute; top: 30px; bottom: 30px; background-repeat: no-repeat; background-size: contain; } #leftpage { background-position: center right; left: 30px; right: 50%; } #rightpage { background-position: center left; left: 50%; right: 30px; }
Comments
Post a Comment