html - Absolute Positioning Inside Absolutly Positioned Div -
i'm relatively new guy html , css sorry if stupid question.
anyway can't seem re-create this:
i converting mobile app webpage. anyway have 'wrapping' make centred when resizing first problem when did not reposition divs inside wrapping when using position:absolute. partly fixed using relative positioning 1 of divs caused me not able put relatively positioned 1 wanted it. question: how arrange icons image , have not move when loaded in different resolutions , when window resized?
/* body */ #body { background-image: url('images/bg-img.jpg'); font-family: museo300-regular, museo700-regular; } /* font */ @font-face { font-family: museo300-regular; src: url(museo300-regular.otf) } /* nav */ #wrapper { margin-left: auto; margin-right: auto; position: absolute; top: 50%; left: 50%; -moz-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); /* ie 9 */ -webkit-transform: translate(-50%, -50%); /* safari */ transform: translate(-50%, -50%); } #home { position: absolute; top: 50%; left: 50%; -moz-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); /* ie 9 */ -webkit-transform: translate(-50%, -50%); /* safari */ transform: translate(-50%, -50%); z-index: 6; } #contact { position: absolute; top: 80%; left: 30%; -moz-transform: translate(-50%, -50%); -ms-transform: translate(-50%, -50%); /* ie 9 */ -webkit-transform: translate(-50%, -50%); /* safari */ transform: translate(-50%, -50%); z-index: 5; }
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>micah friesen</title> <link rel="stylesheet" href="style.css"> <script src="script.js"></script> </head> <body id="body"> <!-- page content --> <!-- navigation --> <div id="wrapper"> <div id="home"> <a href="index.html"> <img src="images/homebttn2.png" title="homepage (here)" /> </a> </div> <div id="contact"> <a href="contact.html"> <img src="images/contactbttn.png" title="contact me, includes rates" /> </a> </div> </div> </body> </html>
for both images (containing icons) here code^
with flex layout, can center quite element, horizontally , vertically.
html { height: 100% } body { background-image: url('images/bg-img.jpg'); font-family: museo300-regular, museo700-regular; display: flex; height: 100%; align-items: center; justify-content: center; } #wrapper { position: relative; } #wrapper > div { border-radius: 50%; width: 100px; height: 100px; overflow: hidden; margin: auto; position: relative; } #wrapper > div#home { width: 150px; height: 150px; } #wrapper > div#contact { width: 100px; height: 100px; left: -150px; top: 10px }