html - How do I align my logo using CSS in my Navigation Bar? -


i creating company website, , have logo, wanting put inside navigation bar, align @ far right, halfway down through height of navigation bar. wanting using css.

here index.html.

<!doctype html> <html> <head>     <title>responsive navigation bar</title>     <link rel="stylesheet" type="text/css" href="main.css">     <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body>     <img src="images/logo.png" alt="logo" id="logo" onclick="location.replace('index.html', '_top')">     <div class="nav">         <label for="toggle">&#9776;</label>         <input type="checkbox" id="toggle"/>         <div class="menu">             <a href="index.html">home</a>             <a href="#business">business</a>             <a href="#services">services</a>             <a href="#learnmore">learn more</a>             <a href="#freetrial"><span id="freetrial">free trial</span></a>         </div>     </div> </body> </html> 

and here main.css

html, body { width: 100%; height: 100%; margin: 0; } html { font-family: "helvetica neue", sans-serif; }  /* navigation bar */  #logo { text-align: right; float: right; }  .nav { border-bottom: 1px solid #eaeaeb; text-align: right; height: 70px; line-height: 70px; } .menu { margin: 0 30px 0 0; } .menu { clear: right; text-decoration: none; color: grey; margin: 0 10px; line-height: 70px; }  #freetrial { color: #54d17a; }  label { margin: 0 40px 0 0; font-size: 26px; line-height: 70px; display: none; width: 26 px; float: right; } #toggle { display: none; }   @media screen , (max-width: 500px) { label {     display: block;     cursor: pointer; } .menu {     text-align: center;     width: 100%;     display: none; } .menu {     display: block;     border-bottom: 1px solid #eaeaeb;     margin: 0;  } #toggle:checked + .menu {     display: block;     background-color: white;   }    } 

if require more explaining or @ in aiding answer question, more happy you, providing can answer haha.

if coding this, first put logo inside nav div own div around it. use flexbox (it supported everywhere ie, btw).

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

make sure apply "display: flex;" parent div (the nav div, presumably). apply "align-items: center;" nav div. align of menu items middle vertically (not sure if want that).

i use "justify-content" nav items. depending on want done other items in nav bar, might use "flex-end" or "space-between".


if not want use flexbox, should refer stack overflow question after moving image inside nav div: how vertically align image inside div?

then set "right: 0;" on image or image div.


also, think may using floats incorrectly...

https://css-tricks.com/all-about-floats/

you seem using them way "seems" should work, can confusing... rid of floats, might messing things up. sorry, can take harder if want @ later time. feel free ask questions have!


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -