![](/img/trans.png)
[英]How can make the div in the photo fill all the white space on the left side? It only fills fully to the right
[英]how can i add another div which will cover all the space present in the right side of .left, .mid and .right?
您好,我想在3個div的右側添加一個div,即left,right和mid,我是CSS新手,如果可以的話,還請解釋如何定位復雜的div設計,或者共享一個鏈接到輕松闡述這個概念的資源這是我完整的源代碼。 這是輸出
<html>
<head>
<title>Template</title>
<style>
body {
background-color: black;
}
.top, .left, .right, .mid, .bottom {
margin: 5px;
background-color: plum;
padding: 5px;
}
.left, .right, .mid {
width: 30%;
}
</style>
</head>
<body>
<div class="top">
<p>Top</p>
</div>
<div class="left">
<p>Left</p>
</div>
<div class="mid">
<p>Mid</p>
</div>
<div class="right">
<p>Right</p>
</div>
<div class="bottom">
<p>Bottom</p>
</div>
</body>
</html>
您可以創建一個帶有2個flex子元素的flex行,並將左flex子元素中的left / mid / right元素設置為您希望它們占據的flex-basis
,然后將另一個flex子元素設置為flex-grow: 1
。 我在這段代碼中使用速記屬性。
body { background-color: black; } .top, .left, .right, .mid, .bottom, .panel2 { margin: 5px; background-color: plum; padding: 5px; } .flex { display: flex; } .panel1 { flex: 0 0 30%; } .panel2 { flex: 1 0 0; background: blue; }
<div class="top"> <p>Top</p> </div> <div class="flex"> <div class="panel panel1"> <div class="left"> <p>Left</p> </div> <div class="mid"> <p>Mid</p> </div> <div class="right"> <p>Right</p> </div> </div> <div class="panel panel2"> foo </div> </div> <div class="bottom"> <p>Bottom</p> </div>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.