[英]CSS media query not overriding styles
我有點困惑。 我首先設計移動設備頁面,因此,如果您在DevTools上打開它,然后在移動設備上看到它,則可以完美地在設備上實現設計。 在grid.css文件的媒體查詢上,我為桌面視圖添加了樣式規則,但是在桌面視圖上打開樣式規則時,它不應用媒體查詢。 如果您想查看https://repl.it/@GianinaSkarlett/API-Capstone
這是一個鏈接,否則為摘錄:
這是CSS樣式(移動設備優先):
* {
font-family: 'Open Sans', sans-serif;
padding: 0;
}
.results {
padding: 10px;
}
.header {
border: solid 1px gainsboro;
padding: 0;
width: 100%;
height: 65px;
}
h1 {
font-size: 3em;
text-align: center;
margin: 0;
}
h2 {
text-align: center;
color: white;
}
.search-background-image {
background: linear-gradient(
to bottom,
rgba(0, 0, 0, 0.5),
rgba(0, 0, 3, 0)
) fixed ,url("https://image.ibb.co/nBhnQA/pexels-photo-1051075-
2.jpg");
background-repeat: no-repeat;
width: 100%;
height: 211px;
background-size: cover;
}
.search-type, .search-address {
background-color: white;
border-radius: 7px;
border: white solid;
position: absolute;
height: 26px;
top: 160px;
padding-left: 3px;
font-size: 9px;
}
.search-address {
width: 110px;
left: 190px;
}
.search-type {
left: 15px;
width: 151px;
}
.button {
background-color: white;
border-radius: 15px;
border: white solid;
position: absolute;
width: 150px;
height: 32px;
left: 90px;
top: 210px;
}
.landing-page, .about-page {
width: 100%;
}
.landing-img {
width: 100%;
border-radius: 10px;
}
.text {
display: inline-block;
text-align: center;
margin: 0;
font-size: 14px;
}
.section-title {
margin: 0;
font-size: 18px;
}
.clear {
clear: both;
}
這是我的桌面媒體查詢:
/* Desktops and laptops ----------- */
@media only screen and (min-width : 1152px) {
/* Styles */
.landing-img {
width: 448.22px;
height: 635px;
border-radius: 10px;
}
.search-type, .search-address {
background-color: white;
border-radius: 7px;
border: white solid;
position: absolute;
height: 40px;
top: 376px;
padding-left: 10px;
}
.landing-page, .about-page {
width: 100%;
}
.section-container {
margin: auto;
}
.landing-img {
width: 448.22px;
height: 330.68px;
border-radius: 10px;
}
.text {
width: 50%;
padding: 20px 0 0 0;
margin: 0;
font-size: 26px;
}
.section-title {
width: 50%;
padding: 0 0 10px 0;
margin: 0;
font-size: 38px;
text-align: left;
}
.right {
float: right;
}
.left {
float: left;
}
.clear {
clear: both;
}
.search-type {
left: 150px;
width: 440px;
}
.search-address {
width: 380px;
left: 650px;
}
.button {
background-color: white;
border-radius: 15px;
border: white solid;
position: absolute;
width: 110px;
height: 40px;
left: 1100px;
top: 376px;
}
}
如果您希望grid.css
覆蓋您的響應式樣式, styling.css
在html文件頭部的styling.css
鏈接之后放置grid.css
鏈接。
我通過刪除現有的媒體查詢並創建2個媒體查詢來使其工作,其中一個針對最大寬度為800px的設備,另一個針對最小寬度為801px的設備。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.