我在嵌套的 div 中有一个树结构。每个嵌套的 div 应该具有相同的宽度。演示该问题的示例:
<!DOCTYPE html>
<html>
<head>
<style>
.CssWrapper {
width: 800px;
overflow: scroll;
border: 1px solid #999;
}
.CssTreeContainer {
width: auto;
display: inline;
float: left;
padding-left:20px;
}
.CssTreeValue {
width: auto;
float: left;
text-align: left;
clear: both;
}
.ParentLabel {
width: auto;
float: left;
text-align: left;
}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div class="CssWrapper">
<div class="CssTreeValue">
<div class="ParentLabel">Main Node A</div>
<div class="CssTreeContainer">
<div class="CssTreeValue">
<div class="ParentLabel">Node AA</div>
<div class="CssTreeContainer">
<div class="CssTreeValue">
<div class="ParentLabel">Node AAA</div>
<div class="CssTreeContainer">
<div class="CssTreeValue">Node AAAA</div>
<div class="CssTreeValue">Node AAAB</div>
</div>
</div>
<div class="CssTreeValue">
<div class="ParentLabel">Node AAB (some extra long text)</div>
<div class="CssTreeContainer">
<div class="CssTreeValue">Node AABA</div>
</div>
</div>
<div class="CssTreeValue">Node AB</div>
</div>
</div>
</div>
</div>
<div class="CssTreeValue">
<div class="ParentLabel">Main Node B</div>
<div class="CssTreeContainer">
<div class="CssTreeValue">
<div class="ParentLabel">Node BA</div>
<div class="CssTreeContainer">
<div class="CssTreeValue">
<div class="ParentLabel">Node BAA</div>
<div class="CssTreeContainer">
<div class="CssTreeValue">Node BAAA</div>
<div class="CssTreeValue">Node BAAB</div>
</div>
</div>
<div class="CssTreeValue">
<div class="ParentLabel">Node BAB</div>
<div class="CssTreeContainer">
<div class="CssTreeValue">Node BABA</div>
</div>
</div>
<div class="CssTreeValue">Node BB</div>
</div>
</div>
</div>
</div>
</div>
<div style="clear:both;" />
<div id="result" />
</body>
</html>