如何使这个DIV以相同的高度开始,即当您删除内容(如标题2中的段落)时,DIV变得不正确(从不同的高度开始)
.holder {
width: 100%;
vertical-align: middle;
text-align: center;
}
.box {
display: inline-block;
width: 400px;
height: 400px;
margin: 15px 15px;
border: 1px solid #333;
}<div class="holder">
<div class="box">
<h4>title 1</h4>
<p>
This is the hidden text that was revealed when the header was clicked. Such hidden text is generally related to the main header which opens them. You can add any number of collapsible headers
</p>
</div>
<div class="box">
<h4>title 2</h4>
<p>
This is the hidden text that was revealed when the header was clicked. Such hidden text is generally related to the main header which opens them. You can add any number of collapsible headers
</p>
</div>
</div>
发布于 2016-03-25 05:53:18
max-height和vertical-align: top;会帮助你。
vertical-align: top工作的主要原因是它被应用于内联块元素。如果.box上的显示只是block,它就不能工作。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>height</title>
<script src="jquery.js"></script>
<script>
$(function(){
})
</script>
<style>
.holder {
width: 100%;
vertical-align: top;
text-align: center;
}
.box {
display: inline-block;
width: 40%;
min-height: 400px;
margin: 15px 15px;
border: 1px solid #333;
vertical-align: top;
}
</style>
</head>
<body>
<div class="holder">
<div class="box">
<h4>title 1</h4>
<p>
This is the hidden text that was revealed when the header was clicked. Such hidden text is generally related to the main header which opens them. You can add any number of collapsible headers
</p>
</div>
<div class="box">
<h4>title 2</h4>
<p>
</p>
</div>
</div>
</body>
</html>
https://stackoverflow.com/questions/36214741
复制相似问题