首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使DIV标签均匀化

使DIV标签均匀化
EN

Stack Overflow用户
提问于 2016-03-25 05:48:37
回答 1查看 37关注 0票数 0

如何使这个DIV以相同的高度开始,即当您删除内容(如标题2中的段落)时,DIV变得不正确(从不同的高度开始)

代码语言:javascript
复制
.holder {
  width: 100%;
  vertical-align: middle;
  text-align: center;
}
.box {
  display: inline-block;
  width: 400px;
  height: 400px;
  margin: 15px 15px;
  border: 1px solid #333;
}
代码语言:javascript
复制
<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>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-25 05:53:18

max-heightvertical-align: top;会帮助你。

vertical-align: top工作的主要原因是它被应用于内联块元素。如果.box上的显示只是block,它就不能工作。

代码语言:javascript
复制
<!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>

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36214741

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档