我想在html/css中創建一個文件層次結構,但我無法獲取這些標籤或divs以擴展爲全寬度。它們只擴展到可見區域的寬度,但我想要它們的寬度。下面是fiddle來查看我在說什麼。灰色區域需要全部排列在右側。如何讓這些div在滾動div內展開爲全寬?
a = 3;
html,
body {
height: 100%;
width: 100%;
padding: 0;
margin: 0;
}
div.hierarchy {
position: relative;
overflow: auto;
border-right: 1px solid grey;
width: 150px;
left: 0;
top: 0;
bottom: 0;
height: 100%;
}
div.hierarchy label {
display: block;
min-width: 100%;
background: #eee;
white-space: nowrap;
}
div.directory {
padding-left: 20px;
width: 100%;
}
div.directory label {
border: 1px solid grey;
width: 100%;
cursor: pointer;
}
<div class="hierarchy">
<label>Hierarchy</label>
<div class="directory">
<label>src</label>
<div class="directory">
<div class="file"><label>test.txt</label></div>
<div class="file"><label>readme.txt</label></div>
<div class="file"><label>a really long filename.txt</label></div>
</div>
</div>
</div>
這樣的兄弟:[鏈接](https://jsfiddle.net/mfzrczpp/1/)鏈接]? – Zaid