jquery - Centering a div with a full width/height border -
first off, here's jfiddle: https://jsfiddle.net/nulyq28d/
what trying make white border expand entire height of screen , center content inside box, both horizontally , vertically. background changing 3 images (instead of solid black) changing between each other. leaving white border part of actual images weird. want separate images.
<body id="home-page"> <main> <div> <p>lorem ipsum dolor sit amet, duis eros posuere sit, volutpat nec massa sit ac, amet pede eu justo, suspendisse adipiscing viverra. amet quisque, justo elit dui orci aliquam praesent, et condimentum nibh. ultricies cubilia eu fringilla elementum erat, arcu metus dictum id feugiat, ultricies interdum elementum, magna nec urna sit non condimentum a, massa tempus nibh. eros turpis in erat sed, adipiscing molestie, eros arcu. est @ est nec augue</p> </div> </main>
body#home-page { background-color: #000000; } body#home-page main { display: table; padding: 20px; width: 88%; border: 8px solid #fff; margin: 20px; } body#home-page main div { text-align: center; margin: 0 auto; vertical-align: middle; width: 50%; } body#home-page main div p { font-size: 12px; color:#fff; line-height: 1.4; letter-spacing: 1px; }
things have tried far include: - absolute positioning content. pushed outside border box , looked awful. - set height won't work since needs responsive.
i think other option @ point capture height of screen through jquery , set height of main height. before wondering if there way through css
vertical alignment acheived in chrome following code
height: 100%; display: flex; align-items: center;
for .main
div, box-sizing: border-box;
added can use 100% width.
html, body need 100% height.
here updated fiddle - https://jsfiddle.net/afelixj/nulyq28d/7/
please check in chrome.
Comments
Post a Comment