在平原CSS中移动中的DIV之间的DIV
我试图将DIV放置在DIVS之间以进行移动屏幕。
我不想使用JavaScript,只是普通CSS。有没有办法实现它?
我正在尝试使用Flexbox Order,但无法实现我的目标。
.parent {
display: flex;
justify-content: flex-start;
}
.left {
background-color: yellow;
padding: 20px;
width: 50%;
}
.left-1 {
background-color: greenyellow;
padding: 20px;
}
.left-3 {
background-color: gray;
padding: 20px;
}
.right {
background-color: cyan;
padding: 20px;
width: 50%;
}
<section class="parent">
<div class="left">
<div class="left-1">1</div>
<div class="left-3">3</div>
</div>
<div class="right">2</div>
</section>
I trying to place a div between divs for a mobile screen.
I don't want to use javascript, just plain css. Is there a way to achieve it?
I'm experimenting with flexboxes order but can't reach my goal.
.parent {
display: flex;
justify-content: flex-start;
}
.left {
background-color: yellow;
padding: 20px;
width: 50%;
}
.left-1 {
background-color: greenyellow;
padding: 20px;
}
.left-3 {
background-color: gray;
padding: 20px;
}
.right {
background-color: cyan;
padding: 20px;
width: 50%;
}
<section class="parent">
<div class="left">
<div class="left-1">1</div>
<div class="left-3">3</div>
</div>
<div class="right">2</div>
</section>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实现所需结果的最简单方法是使用CSS网格布局,该布局允许所有元素是兄弟姐妹,以及媒体问题:
JS小提琴演示。
参考:
box> box-sizing
。display 。
font-family
。
gap
。
grid> grid> grid-template-areas-areas
。
@media
QUERIES。
参考书目:
The easiest way to achieve your desired outcome is to use CSS grid layout, which allows for all elements to be siblings, along with a media-query:
JS Fiddle demo.
References:
box-sizing
.display
.font-family
.font-size
.font-weight
.gap
.grid-template-areas
.margin
.@media
queries.padding
.Bibliography: