html - Change navigation from floating right to centered when resized -


i've searched , searched , found similar issues, none of previous threads me solve problem. on desktop home page, have navigation menu floating right. however, when resized or viewing on mobile device, want menu items centered rather floating right, looks messy. i've tried various suggestions other posts, nothing seems working , it's driving me nuts. i've tried media queries change alignment below size , have been unsuccessful must doing wrong. also, not big priority, noticed header logo gets ever-so-slightly clipped in mobile version, great if me well. thank in advance help!

please see attached screen shots. desktop version mobile version

edit: sorry forgot post code. college class, right css , html combined 1 document, later have separate style sheet. also, live version can seen @ geocities.ws/dinetown

<!doctype html>  <html>    <head>  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">    <style>    #container {   min-height: 100%;   position: relative;  }    #header {   padding: 1em;   color: white;   background: black;    text-align: left;  }    #content {   padding-bottom: 50px;  }    footer {   height: 50px;   line-height: 50px;   left:0px;   bottom:0px;   position: absolute;   width: 100%;   display: inline-block;   color: white;   background: black:   font-family: majesti;   background: black;    text-align: center;   vertical-align: center;  }    .header img {    float: left;    background: black;    width:100%;    overflow: hidden;  }    ul {   list-style-type: none;   margin: 0;   padding: 0;   overflow: hidden;   width: 100%;   background-color: rgb(190, 30, 45);   font-family: athelas;  }    li {   float: right;  }    li {   float: right;   display: block;   color: white;   text-align: center;   padding: 14px 16px;   text-decoration: none;  }    li a:hover {   background-color: maroon;  }    html,  body {   margin: 0;   padding: 0;   height: 100%;   font-family: athelas;    color: white;   background: rgb(65, 57, 61);  }    p {   padding-left: 30px;   padding-right: 30px;   padding-top: 15px;   padding-bottom: 15px;  }    </style>      <title>welcome town</title>    </head>      <body style="margin: 0;">  <div id="container">     <div id="header">    <img src="images/logo.svg" width="400px">   </div>      <div id="content">     <ul>      <li><a href="contact.html">contact</a></li>      <li><a href="about.html">about us</a></li>      <li><a href="gallery.html">gallery</a></li>      <li><a href="social.html">social hour</a></li>      <li><a href="menu.html">menu</a></li>      <li><a class="active" href="index.html">home</a></li>     </ul>         <section style="margin: 0;">      <img src="images/dining_room.png" width="100%" overflow="hidden">     </section>       <article>      <p align="center">       our mission bring <b><i>quality</i></b>, <b><i>style</i></b> , wish        <b><i>good fortune</i></b> of our guests. provide high-end dining        experience through chinese cuisine.      </p>     </article>   </div>    <footer>  &copy; 2017 andrew struppa  </footer>      </div>  </body>  </html>

add min-width media query , put float:right of navigation menu in there. if want position of navigation centered, give set width, display:block , margin:auto; in min-width media query can make width:auto counteract set width.

edit: see have updated post code, can remove float li, add display:inline-block , have media query on ul text-align center , right. without float, you'll have re-order menu though.

<!doctype html>  <html>    <head>  <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0">    <style>    #container {   min-height: 100%;   position: relative;  }    #header {   padding: 1em;   color: white;   background: black;    text-align: left;  }    #content {   padding-bottom: 50px;  }    footer {   height: 50px;   line-height: 50px;   left:0px;   bottom:0px;   position: absolute;   width: 100%;   display: inline-block;   color: white;   background: black:   font-family: majesti;   background: black;    text-align: center;   vertical-align: center;  }    .header img {    float: left;    background: black;    width:100%;    overflow: hidden;  }    ul {   list-style-type: none;   margin: 0;   padding: 0;   overflow: hidden;   width: 100%;   background-color: rgb(190, 30, 45);   font-family: athelas;   text-align:center;  }    li {   display:inline-block;  }    li {   float: right;   display: block;   color: white;   text-align: center;   padding: 14px 16px;   text-decoration: none;  }    li a:hover {   background-color: maroon;  }    html,  body {   margin: 0;   padding: 0;   height: 100%;   font-family: athelas;    color: white;   background: rgb(65, 57, 61);  }    p {   padding-left: 30px;   padding-right: 30px;   padding-top: 15px;   padding-bottom: 15px;  }  @media screen , (min-width: 768px) {  ul{  text-align:right;  }  </style>      <title>welcome town</title>    </head>      <body style="margin: 0;">  <div id="container">     <div id="header">    <img src="images/logo.svg" width="400px">   </div>      <div id="content">     <ul>      <li><a href="contact.html">contact</a></li>      <li><a href="about.html">about us</a></li>      <li><a href="gallery.html">gallery</a></li>      <li><a href="social.html">social hour</a></li>      <li><a href="menu.html">menu</a></li>      <li><a class="active" href="index.html">home</a></li>     </ul>         <section style="margin: 0;">      <img src="images/dining_room.png" width="100%" overflow="hidden">     </section>       <article>      <p align="center">       our mission bring <b><i>quality</i></b>, <b><i>style</i></b> , wish        <b><i>good fortune</i></b> of our guests. provide high-end dining        experience through chinese cuisine.      </p>     </article>   </div>    <footer>  &copy; 2017 andrew struppa  </footer>      </div>  </body>  </html>


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -