@media only screen and (max-width: 480px) {
}
@media only screen and (max-width: 767px) {
html{
font-size: 20px;
max-width: 767px;
}
.main-nav li{
padding: 0;
}
.main {
margin: 0px auto;
padding-top: 4px;
font-size: 65%;
}
h1{
font-size: 120%;
}
.welcome {
position: absolute;
width: 767px;
}
.p1{
color: white;
font-size: 10px;
transform: translate(5%, 10%);
margin: 0;
}
.section1 {
background-color: #ffffff;
background-image: linear-gradient(rgba(93, 91, 91, 0.67), rgba(93, 91, 91, 0.67)), url(img/patrick-tomasso-71909-unsplash.jpg);
background-size: cover;
background-position: center;
}
@media only screen and (max-width: 1023px) {
.welcome {
font-size: 120%;
width: 1023px;
}
.sec-1{ margin-left: 30px; }
.sec-1-ul li a,
.sec-2-ul li a,
.sec-3-ul li a {
font-size: 80%;
}
.p1{
margin: 10%;
color: white;
font-size: 100%;
transform: translate(5%, 10%)
}
}
@media only screen and (max-width: 1200px) {
.section1 {
background-color: #ffffff;
background-image: linear-gradient(rgba(93, 91, 91, 0.67), rgba(93, 91, 91, 0.67)), url(img/patrick-tomasso-71909-unsplash.jpg);
background-size: cover;
background-position: center;
height: 70vh;
}
.logo{
margin-left: 5px;
}
.p1{
font-size: 150%;
transform: translate(0%, 0%);
max-width: 100%;
}
h4{
font-size: 120%;
}
.sec-1,
.sec-2,
.sec-3{
margin-top: 0px;
}
.sec-1-ul li a,
.sec-2-ul li a,
.sec-3-ul li a {
font-size: 90%;
}
h3{
font-size: 120%;
margin-top: 2px;
margin-left: 20%;
}
}
我是网络开发的新手。我正在使用媒体查询进行响应式web开发。我在我的文件中定义了4个屏幕宽度。但是,如果我在一个宽度中定义了任何css属性的值,我就不能在其他宽度中更改它。例如,如果1200px中的一个标题的字体大小是80px,我无法将其更改为1023px的40px,并保持不变。错误是什么?
发布于 2018-05-28 21:49:12
如果使用最大宽度,则必须以相反的方式对媒体查询进行排序:首先是max-width: 1200px,然后是1023px,然后是767px。
按照现在的方式,上一次媒体查询中的规则将始终覆盖前面的规则,因为顺序也是相关的(后面的将覆盖之前的),并且max-width: 1200px也适用于较小的宽度。如果你让他们转过来,那就不会发生了。
https://stackoverflow.com/questions/50556524
复制相似问题