我有我的网页上两列:CSS - 交换柱
Left-Column Right-Column
在手机和平板设备,我想右栏向左一前显示。例如:
<p>Right-Column</p>
<p>Left-Column</p>
任何人如何使用CSS做到这一点?我知道我可以使用Bootstrap来完成,但WordPress模板并非使用Bootstrap设计的。
感谢
我有我的网页上两列:CSS - 交换柱
Left-Column Right-Column
在手机和平板设备,我想右栏向左一前显示。例如:
<p>Right-Column</p>
<p>Left-Column</p>
任何人如何使用CSS做到这一点?我知道我可以使用Bootstrap来完成,但WordPress模板并非使用Bootstrap设计的。
感谢
不是很难,只是定位在媒体查询扮演相反的其他元素的宽度:
.left {
width: 75%;
background: red;
}
.right {
width: 25%;
background: blue;
}
@media (max-width: 992px) {
.left {
left: 25%;
}
.right {
right: 75%;
}
}
你的问题不是很清楚。
但是根据目前的知识,左列的float:right
和右列的 float:left
。
观看演示:
http://jsfiddle.net/srmpx6Lp/2/
如果你给你的代码,我可以更好地了解需要
如果你不关心浏览器的支持,您可以使用flexbox
这一点。
.container {
display: flex;
}
.container > div {
width: 50%;
padding: 0 15px;
}
@media (max-width: 600px){
.left-col {
order: 2;
}
.right-col {
order: 1;
}
}
这应该在所有主要浏览器,并在IE10和后续工作。见CanIuse。
某些浏览器仍需要此功能的前缀。
我会用柔性盒和媒体查询:
#parent {
display: flex;
flex-wrap:wrap
}
#parent > div {
flex: 1 1 40%;
}
@media only screen and (max-device-width: 500px) {
#parent > div {
flex: 1 1 100%;
}
#left {
order: 2;
}
#right {
order: 1;
}
}
<div id="parent">
<div id="left">
<span>Left</span>
</div>
<div id="right">
<span>Right</span>
</div>
</div>
我们怎么提供给你一个工作的答案没有看到相关的代码? http://stackoverflow.com/help/how-to-ask – Aaron