为什么我的媒体查询会影响每个宽度,而不仅仅是针对我设置的 (max-width: 860px)?
Why is my media query affecting every width and not just targeting the (max-width: 860px) which I set?
我正在为一个网站设计样式,并且按照我的意愿拥有它,直到 - 我添加了媒体查询...
它只是一个针对 860 像素及更小设备(最大宽度:860 像素)的媒体查询...
然而,即使在更宽的屏幕上,媒体查询也会以某种方式生效,实际上弄乱了我的整个布局...我将它放在单独的 .css 文件中,因为我想检查是否一切正常我没有 link 媒体查询 .css 文件 - 是的 - 没有它一切正常......
我真的不明白是什么导致了媒体查询的行为。我在发布此问题之前进行了搜索,但找不到此特定问题。
谁能帮我解决这个问题?这是我的 media.css -
@media (max-width: 860px) {
.navbar span {
display: none;
}
.navbar h2 {
display: none;
}
.navbar img {
width: 50px;
/* padding: 0 15px; */
display: flex;
flex-direction: row;
}
.navbar {
display: flex;
justify-content: space-between;
}
.hide {
display: none;
}
.section-1 {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 0;
}
.mobile-img {
display: block;
width: 100%;
margin-bottom: 0;
}
.section-1-content {
display: block;
width: 100%;
margin: 0;
}
.section-1 h1 {
font-size: 10vw;
line-height: 10vw;
margin-top: -8vw;
}
.section-1 p {
font-size: 5vw;
line-height: 6vw;
}
.section-1 .btn {
background-color: #9b9b9b;
width: 100%;
}
.section-2-left {
display: none;
}
.section-2 {
display: flex;
flex-direction: column;
width: 100%;
}
.section-2 .content-right {
display: inline-block;
width: 100%;
}
.box-side {
display: block;
border: none;
}
.section-2 .box-side-text {
display: flex;
flex-direction: column;
width: 100%;
}
.section-2 h4 {
font-size: 5vw;
padding-bottom: 2vw;
}
.section-2 p {
font-size: 4vw;;
}
.section-2 a {
font-size: 4vw;;
}
.section-3 h3 {
font-size: 7vw;
font-weight: 780;
}
.section-3 {
/* display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%; */
}
/* .grid {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 90%; */
}
.box {
display: flex;
flex-direction: column;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
}
.row-1, .row-2, .text-wrap-grid {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
}
.text-wrap-grid {
background-color: #d8d8d8;
}
/* display: block; */
/* display: flex;
flex-direction: column;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
*/
.section-3 h4 {
font-size: 3.5vw;
}
.section-4 h3 {
font-size: 7vw;
font-weight: 780;
}
.section-4-all {
display: flex;
flex-direction: column;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
}
.section-4-left {
display: flex;
flex-direction: column;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
}
video {
width: 100%;
}
}
这是因为你没有正确设置媒体查询。请尝试
@media only screen and (max-width: 860px) {
}
看看这是否有效。
我发现了一个问题 - 当我评论东西时 - 我不小心遗漏了几个 }
只是闲逛,这导致了错误。
我正在为一个网站设计样式,并且按照我的意愿拥有它,直到 - 我添加了媒体查询... 它只是一个针对 860 像素及更小设备(最大宽度:860 像素)的媒体查询...
然而,即使在更宽的屏幕上,媒体查询也会以某种方式生效,实际上弄乱了我的整个布局...我将它放在单独的 .css 文件中,因为我想检查是否一切正常我没有 link 媒体查询 .css 文件 - 是的 - 没有它一切正常......
我真的不明白是什么导致了媒体查询的行为。我在发布此问题之前进行了搜索,但找不到此特定问题。
谁能帮我解决这个问题?这是我的 media.css -
@media (max-width: 860px) {
.navbar span {
display: none;
}
.navbar h2 {
display: none;
}
.navbar img {
width: 50px;
/* padding: 0 15px; */
display: flex;
flex-direction: row;
}
.navbar {
display: flex;
justify-content: space-between;
}
.hide {
display: none;
}
.section-1 {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
margin: 0;
}
.mobile-img {
display: block;
width: 100%;
margin-bottom: 0;
}
.section-1-content {
display: block;
width: 100%;
margin: 0;
}
.section-1 h1 {
font-size: 10vw;
line-height: 10vw;
margin-top: -8vw;
}
.section-1 p {
font-size: 5vw;
line-height: 6vw;
}
.section-1 .btn {
background-color: #9b9b9b;
width: 100%;
}
.section-2-left {
display: none;
}
.section-2 {
display: flex;
flex-direction: column;
width: 100%;
}
.section-2 .content-right {
display: inline-block;
width: 100%;
}
.box-side {
display: block;
border: none;
}
.section-2 .box-side-text {
display: flex;
flex-direction: column;
width: 100%;
}
.section-2 h4 {
font-size: 5vw;
padding-bottom: 2vw;
}
.section-2 p {
font-size: 4vw;;
}
.section-2 a {
font-size: 4vw;;
}
.section-3 h3 {
font-size: 7vw;
font-weight: 780;
}
.section-3 {
/* display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%; */
}
/* .grid {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 90%; */
}
.box {
display: flex;
flex-direction: column;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
}
.row-1, .row-2, .text-wrap-grid {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
}
.text-wrap-grid {
background-color: #d8d8d8;
}
/* display: block; */
/* display: flex;
flex-direction: column;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
*/
.section-3 h4 {
font-size: 3.5vw;
}
.section-4 h3 {
font-size: 7vw;
font-weight: 780;
}
.section-4-all {
display: flex;
flex-direction: column;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
}
.section-4-left {
display: flex;
flex-direction: column;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
}
video {
width: 100%;
}
}
这是因为你没有正确设置媒体查询。请尝试
@media only screen and (max-width: 860px) {
}
看看这是否有效。
我发现了一个问题 - 当我评论东西时 - 我不小心遗漏了几个 }
只是闲逛,这导致了错误。