В адаптивном режиме Firefox работает нормально, но не в Chrome.

* {
    margin: 0;
    padding: 0;
}

body {
    background: royalblue;
    font-family: monospace;
}

header {
    position: relative;
    top: 0px;
    margin: 0 auto;
    width: 100%;
    background: red;
}

.nav {
    position: relative;
    top: 0px;
    list-style: none;
    text-align: center;
    padding: 10px 0;
}

.nav li {
    margin: -3px;
    display: inline-block;
    padding: 7px 3px;
    border-left: 1px solid silver;     
}

#log {
    border-right: 1px solid silver;
}

.nav a {
    position: relative;
    text-decoration: none;
    color: silver;
    padding: 10px 50px;
    font-size: 15px;        
}

li:hover {
    background: black;
}

/* 800px  ============================= */

@media screen and (max-width: 820px) {

body {
        background: green;
    }

.nav {
    position: relative;
    top: 0px;
    list-style: none;
    text-align: center;
    padding: 8px 0; /* nav padding */
}

.nav li {
    margin: -3px;
    display: inline-block;
    padding: 2px 3px;
    border-left: 1px solid silver;

}

#log {
    border-right: 1px solid silver;
}

.nav a {
    position: relative;
    text-decoration: none;
    color: silver;
    padding: 5px 40px;
    font-size: 14px;
  }
}

/* 680px  ============================= */

@media screen and (max-width:681px) {

body {
        background: royalblue;
    }

.nav {
    position: relative;
    top: 0px;
    list-style: none;
    text-align: center;
    padding: 8px 0; /* nav padding */
}

.nav li {
    margin: -3px;
    display: inline-block;
    padding: 2px 3px;
    border-left: 1px solid silver
}

#log {
    border-right: 1px solid silver;
}

.nav a {
    position: relative;
    text-decoration: none;
    color: silver;
    padding: 5px 30px;
    font-size: 14px;
  }
}

/* 500px  ============================= */

@media screen and (max-width: 590px) {

body {
        background: green;
    }

.nav {
    position: relative;
    top: 0px;
    list-style: none;
    text-align: center;
    padding: 8px 0; /* nav padding */
}

.nav li {
    margin: -3px;
    display: inline-block;
    padding: 2px 3px;
    border-left: 1px solid silver;
}

#log {
    border-right: 1px solid silver;
}

.nav a {
    position: relative;
    text-decoration: none;
    color: silver;
    padding: 5px 25px;
    font-size: 13px;
  }
}
<body>
    <header>
        <ul class="nav">   
            <li><a href="homepage.html">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Contact</a></li>
            <li><a href="#">Services</a></li>
            <li id="log"><a href="index.html">Login</a></li>           
       </ul>        
     </header> 
</body>
1
yalpsid 23 Сен 2018 в 11:16

1 ответ

Лучший ответ

Вы пробовали добавить <meta name="viewport" content="width=device-width,initial-scale=1"> в раздел <head> вашего html-кода.

2
DylanT 25 23 Сен 2018 в 08:38