我希望我的 3 个子 div 垂直拉伸(stretch) 100%,并且我希望它们水平相邻。因此,如果我调整父 div 的大小,子 div 将相应地调整大小,但会始终保持水平相邻(每个将占用大约 33% 的宽度)
这是 CSS:
.appcontent {
position: absolute;
left: 80px;
right: 50px;
top: 30px;
max-width: 1050px;
min-height: 400px;
border: 2px solid black;
}
.box {
display: inline-block;
height: 98%;
padding: 10px;
border: 2px solid black;
}
和 HTML:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery demo</title>
<script src="jquery.js"></script>
<script src="index.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="appcontent">
<div class="box">
<h3>App 1</h3>
</div>
<div class="box">
<h3>App 2</h3>
</div>
<div class="box">
<h3>App 3</h3>
</div>
</div>
</body>
</html>
以防万一我也把它放在这里http://jsfiddle.net/naWsh/
最佳答案
我之前回答过这个问题,解释很全面Fluid design
将 400% 改为 100% 及其子级 33%
关于css - 如何在另一个div中拉伸(stretch)div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14346445/