解释为什么@media 不适用于 768 像素。我知道问题在网格≥768px,但是如何解决呢?
*{
margin: 0;
padding: 0;
font-size: 10px;
}
/*-------------------------------------- header ---------------------------- */
.header-menu-col {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-top: 40px;
}
.header-section {
background-color: #e9e9e9;
padding: 30px 0 90px ;
}
.header-section .menu ul{
display: flex;
list-style-type: none;
}
.header-section .menu ul a{
text-decoration: none;
padding: 0 15px;
color: #191919;
font-family: "Montserrat";
font-size: 12px;
font-weight: bold;
line-height: 24px;
text-transform: uppercase;
}
.header-section .menu ul a:hover {
color: #10c9c3;
}
.header-section .menu ul a.active{
color: #10c9c3;
letter-spacing: 1.2px;
}
.caption-header {
justify-content: flex-end;
}
.caption-header h1{
color: #1d1d1d;
font-family: "Montserrat";
font-size: 38px;
font-weight: bold;
line-height: 48px;
}
.caption-header p{
color: #787878;
font-family: "Nunito Sans";
font-size: 18px;
font-weight: 400;
line-height: 28px;
padding: 25px 0;
}
.caption-header-row {
justify-content: flex-end;
margin-top: 150px;
}
.caption-header-row a{
padding: 20px 40px;
background-color: #10c9c3;
color: #FFF;
font-family: "Montserrat";
font-size: 12px;
font-weight: 500;
line-height: 84px;
text-transform: uppercase;
letter-spacing: 1.2px;
text-decoration: none;
}
.caption-header-row a:hover {
box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
@media (max-width: 768px) {
.menu {
display: none;
}
.caption-header-row {
margin-top: 50px;
}
.header-menu-col {
justify-content: center;
}
.caption-header {
text-align: center;
}
}
/*-------------------------------------- /header ---------------------------- */
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1" content="width=device-width">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Montserrat|Raleway" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="style/style.css">
</head>
<body>
<div id="header" class="header-section">
<div class="container">
<div class="row">
<div class="col-xl-12 header-menu-col">
<div class="logo">
<a href="#"><img src="image/logo.png" width="31px" height="25px" alt="logo"></a>
</div>
<div class="menu">
<ul>
<li class="menu-item"><a class="active" href="#home">home</a></li>
<li class="menu-item"><a href="#about">about</a></li>
<li class="menu-item"><a href="#work">work</a></li>
<li class="menu-item"><a href="#process">process</a></li>
<li class="menu-item"><a href="#services">services</a></li>
<li class="menu-item"><a href="#testcontact">testcontact</a></li>
<li class="menu-item"><a href="#contact">Contact</a></li>
</ul>
</div><!-- /============================= /menu =========================== !-->
</div><!-- /============================= /col logo =========================== !-->
</div>
<div class="row caption-header-row">
<div class="col-md-6 col-sm-12">
<div class="caption-header">
<h1>We Design and Develop</h1>
<p>We are a new design studio based in USA. We have over
20 years of combined experience, and know a thing or two
about designing websites and mobile apps.</p>
<a href="#">contact us</a>
</div>
</div><!-- /============================= /col menu =========================== !-->
</div><!-- /============================= /row =========================== !-->
</div><!-- /============================= /container =========================== !-->
</div><!-- /============================= /section =========================== !-->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
</body>
</html>
因为您没有为这些权限指定阻止行为
在这里,您将其从 ≥768px ( ) 写入
.col-md-6
并从 ≥576px ( ) 更改.col-sm-12
。使用类添加最多 <576px 的行为.col-{n}
。