html - CSS媒体查询不覆盖样式
问题描述
我有点困惑。我首先设计了我的页面移动设备,因此如果您在 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
覆盖响应式样式,请将链接放在html 文件头部的链接grid.css
之后。styling.css
推荐阅读
- javascript - 是否可以在托管网页的服务器上运行倒数计时器?
- ios - iOS:应用内购买提醒视图/弹出窗口
- ionic-framework - 离子 - 用于 svg 中 rect 的 for 循环
- node.js - ES6 从内部函数返回
- windows - 如何在用户注销时自动将双显示器的显示设置更改为“镜像”?
- php - 如何使用 PHP 根据键值对 json 数组进行排序
- sql - 通过批处理登录后选择(Microsoft SQL Server Management Studio)
- linux - Cytoscape 和 linux
- python - 如何从python中的大图像中提取图片
- python - 如何构建个性化排列