Alignment against parent div with CSS/HTML -
i'm working on little project buddy's band , switched new navbar. how it's layed out logo in center, , page links left/right of it. far that's working fine, wanted add text or maybe image right , can't figure out how navbar set center everything. example shown in image here: http://i.imgur.com/3slwdux.png
keep in mind navbar stays on top of screen.
here's looks @ moment, had use span2
css:
.fixed-nav-bar { position: fixed; top: 0; z-index: 9999; width: 100%; height: 100px; background-color: #000; display: table; } span2 { display: table-cell; vertical-align: middle; position: relative; }
html:
<nav class="fixed-nav-bar"> <style> ul { list-style-type: none; overflow: hidden; background-color:000; } li { display: inline-block; } li { display: inline-block; color: white; padding: 14px 16px; text-decoration: none; } li a:hover { background-color: #111; } </style><span2> <ul><center> <li><a class="active" href="#home">home</a></li> <li><a href="#about">about</a></li> <li><a href="#video">video</a></li> <li><img src="http://i.imgur.com/8iu55ho.png"></li> <li><a href="#music">music</a></li> <li><a href="#press">press</a></li> <li><a href="#contact">contact</a></li></center> </ul></span2> </nav>
any appreciated!
if want ul
stay on center of page think have use position: absolute
text on right side goes out of elements flow. should
nav { position: fixed; background: black; height: 100px; width: 100%; } ul { list-style-type: none; display: flex; justify-content: center; align-items: center; margin: 0 auto; } { color: white; padding: 0 10px; text-decoration: none; } .nav-inner { position: relative; height: 100%; width: 100%; display: flex; align-items: center; justify-content: center; } .text { color: white; position: absolute; top: 50%; right: 20px; transform: translatey(-50%); } img { width: 50px; }
<nav> <div class="nav-inner"> <ul> <li><a href="">link</a></li> <li><a href="">link</a></li> <li><a href="">link</a></li> <li><a href=""><img src="http://i.imgur.com/8iu55ho.png"></a></li> <li><a href="">link</a></li> <li><a href="">link</a></li> <li><a href="">link</a></li> </ul> <div class="text">lorem ipsum</div> </div> </nav>
Comments
Post a Comment