【发布时间】:2020-01-05 16:20:39
【问题描述】:
我的网站使用 bootstrap 4 和我制作的 css 文件。
在这个 css 文件的底部,我放了一些媒体查询:
@media (max-width: 575px) {
.address .contact {
text-align: center;
}
}
/* Small devices (tablets, 768px and up) */
@media (min-width: 768px) {
}
/* Medium devices (desktops, 992px and up) */
@media (min-width: 992px) { }
/* Large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) { }
@media screen and (min-width:768px) and (max-width:992px){
.left{
margin-left: 0;
width: 100%;
}
.picto{
width: 40%;
}
}
下面是部分代码:
<section id="section_address" class="container">
<div class="row">
<div class="col-12 col-sm-6">
<div class="address">
<h5>ADDRESS</h5>
1 street,<br>
75000, PARIS
</div>
</div>
<div class="col-12 col-sm-6">
<div class="contact">
<h5>MYCOMPANY</h5>
01 11 22 33 44<br>
contact@mycompany.com<br>
<a href="http://mycompany.com" target="_blank">http://mycompany.com</a>
</div>
</div>
</div>
</section>
但我的媒体查询不起作用,除非我将!important 添加到每一行。但是我不能对每一行都这样做,而且我已经使用了媒体查询,而且我从来不需要这样做。
【问题讨论】:
-
其他文件可能会影响您的样式。比如它被包含的顺序。
-
您是否尝试将样式表移动到 head 标签的底部(即列表中的最后一个样式表)?
标签: css bootstrap-4 media-queries