就像上面的图片。如何使用col-lg-6
使最右侧的列占据网格系统下面的行。第一和第二列将是col-lg-6
,下面的列也将是col-lg-6
。我在最右边的一栏使用float right使某些工作正常。但是我可以使用display:relative;
来创建这样的列吗?
使用网格区域是一种简单的方法。试试这个:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
.parentDiv{
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-areas: "firstdiv thirddiv" "seconddiv thirddiv";
grid-gap: 10px;
}
.firstdiv{
grid-area: firstdiv;
background: black;
width: 100%;
height: 100px;
}
.seconddiv{
grid-area: seconddiv;
background: green;
width: 100%;
height: 100px;
}
.thirddiv{
grid-area: thirddiv;
background: red;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div class="parentDiv">
<div class="firstdiv">
</div>
<div class="seconddiv">
</div>
<div class="thirddiv">
</div>
</div>
</body>
</html>