【发布时间】:2020-04-08 15:13:58
【问题描述】:
【问题讨论】:
-
您能否分享您尝试实现此布局的代码?
-
你已经尝试过什么,为什么没有成功?
-
@BenM 组件没有响应
-
stackoverflow.com/help/someone-answers 通过投票和接受答案(如果有效)来提供帮助
【问题讨论】:
像这样,如果你在没有花哨的 flexbox 的情况下这样做:
<div class="wrapper">
<div class="right"></div>
<div class="left">
<div class="inner-top"></div>
<div class="inner-bottom"></div>
</div>
</div>
.wrapper {
height: 200px;
position: relative;
width: 100%;
}
.right {
width: 50%;
background-color: blue;
height: 100%;
display:inline-block;
float: left;
}
.left {
width: 50%;
background-color: red;
height: 100%;
display: inline-block;
}
.left .inner-top {
height: 50%;
width: 100%;
background-color: yellow;
}
.left .inner-bottom {
height: 50%;
width: 100%;
background-color: green;
}
【讨论】:
<!DOCTYPE html>
<html>
<head>
<style>
.grid-container {
display: grid;
grid-gap: 10px;
background-color: #2196F3;
padding: 10px;
}
.grid-item {
background-color: rgba(255, 255, 255, 0.8);
text-align: center;
padding: 20px;
font-size: 30px;
}
.item1 {
grid-column: 2 / span 1;
grid-row: 1;
}
.item2 {
grid-column: 1;
grid-row: 1 / span 2;
}
</style>
</head>
<body>
<h1>A Three Items Grid Layout:</h1>
<div class="grid-container">
<div class="grid-item item1">1</div>
<div class="grid-item item2">2</div>
<div class="grid-item item3">3</div>
</div>
</body>
</html>
【讨论】: