gpt4 book ai didi

html - 我们能否在媒体查询的所有屏幕分辨率中只使用任何属性的一个值?

转载 作者:行者123 更新时间:2023-11-28 01:38:29 26 4
gpt4 key购买 nike

@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 属性的值,则无法在其他宽度中更改它。例如,如果 1200 像素的一个标题的字体大小为 80 像素,我无法将其更改为 1023 像素的 40 像素并保持不变。错误是什么?

最佳答案

如果使用最大宽度,则必须以相反的方式对媒体查询进行排序:首先是 max-width: 1200px,然后是 1023px,然后是 767px。

你现在拥有它们的方式最后一个媒体查询中的规则将始终覆盖前面的规则,因为顺序也是相关的(后面的将覆盖前面的),并且 max-width: 1200px也适用于较小的宽度。如果您扭转局面,那将不会发生。

关于html - 我们能否在媒体查询的所有屏幕分辨率中只使用任何属性的一个值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50556524/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com