CSS 等高柱

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CSS 等高柱相关的知识,希望对你有一定的参考价值。

// HTML

<div class="equal">
	<div class="row">
		<div class="one">

			<h2>This is a box</h2>
			<p>This box has less content than the one next to it, but both boxes will still have equal height. No background-image trickery.</p>
		</div>
		<div class="two">
        	<h2>This is another box</h2>
			<p>This box has more content than the others. If all boxes were table cells, the cell with the most content would decide the height of all cells. It works like that here too, but this is not a table.</p>
			<p>Instead, display:table, display:table-row and display:table-cell are used to make divs behave like table cells. Excellent. Too bad it doesn’t work in you-know-which-browser. It does, however, work in modern browsers like Mozilla, Opera, Safari, Firefox, OmniWeb, Camino, and Netscape.</p>

			<p>Read the related blog entry for more info: <a href="/archive/200405/equal_height_boxes_with_css/">Equal height boxes with CSS</a>.</p>
		</div>
		<div class="three">
			<p>This box has even less content. Anything in it is vertically centered.</p>
		</div>
	</div>
</div>


// CSS

/* Layout rules */
	.equal {
		display:table;
		border-collapse:separate;
	}
	.row {
		display:table-row;
	}
	.row div {
		display:table-cell;
	}
	
	/* Styling rules to make the example look nicer */
	html,body {
		margin:0;
		padding:0;
		color:#000;
		background:#fff;
	}
	body {
		font:76%/140% "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif;
	}
	.equal {
		margin:10px auto;
		border-spacing:10px;
		background:#898B60;
		width:80%;
	}
	.row div {
		background:#fff;
	}
	.row div.one {
		width:40%;
	}
	.row div.two {
		width:40%;
	}
	.row div.three {
		vertical-align:middle;
	}
	.row div h2 {
		margin:0 0 0.5em 0;
		padding:0.5em 10px;
		font-size:1.2em;
		color:#fff;
		background:#595B30;
	}
	.row div p {
		font-size:0.94em;
		margin:0.5em 0;
		padding:0 10px;
	}
	#labfooter {
		text-align:center;
	}

以上是关于CSS 等高柱的主要内容,如果未能解决你的问题,请参考以下文章

等高柱由960.gs框架组成

html Bootstrap等高柱

html Bootstrap等高柱

JavaScript 坚如磐石的等高柱

坚固的等高柱

等高柱