【发布时间】:2017-06-13 04:33:48
【问题描述】:
我遇到了媒体查询问题。我想将容器的width 属性更改为页面的100%,但它不适用。我使用引导程序作为 CSS 框架。我给你一个检查员的镜头:
代码:
<div class="container-flex" id="blog-posts">
<div class="post-left">
<div>
<img class="img-responsive" src="images/content/blog/post-image.jpg">
</div>
</div>
<div class="divider">
<div class="divider-dot"></div>
<div class="divider-line"></div>
</div>
<div class="post-right">
<div>
<time>10 April 2014</time>
<h3>Typi non habent claritatem insitam</h3>
<p>Duis autem vel eum iriure dolor in hendreit in vulputate velit esse molestie consequat vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui [...]</p>
</div>
</div>
</div>
CSS:
@media only screen and (max-width : 767px) {
#blog-posts {
display: flex;
flex-direction: column;
width: 100%;
border: 1px solid blue;
.divider {
display: none;
}
.post-left {
;
width: 100%;
div {
//width: 100%;
border: 1px solid;
}
}
.post-right {
width: 100%;
div {
width: 100%;
border: 1px solid;
}
}
}
}
...
#blog-posts {
display: flex;
.post-left {
width: 47.95%;
//border: 1px solid blue;
div {
width: 50%;
float: right;
img {
float: right;
}
}
}
.divider {
//border: 1px solid;
width: 4.1%;
.divider-dot {
border-radius: 50%;
background-color: rgb(235, 235, 235);
width: 17px;
height: 17px;
margin: 0 auto;
}
.divider-line {
width: 1px;
height: 100%;
background-color: rgb(235, 235, 235);
margin: 0 auto;
}
}
.post-right {
//border: 1px solid green;
width: 47.95%;
div {
width: 50%;
time {
font-size: 16px;
font-family: "Raleway";
color: rgb(123, 108, 99);
line-height: 1.875;
text-align: left;
}
h3 {
font-size: 24px;
font-family: "Raleway";
color: rgb(33, 33, 33);
line-height: 1.25;
text-align: left;
}
p {
font-size: 16px;
font-family: "Raleway";
color: rgb(148, 148, 148);
line-height: 1.875;
text-align: left;
}
}
}
}
【问题讨论】:
-
确保将媒体查询放在实际样式之后,否则将无法继承。
标签: html css twitter-bootstrap responsive-design media-queries