div垂直水平居中

.block {
			text-align: center;
		}

		.block:before {
			display: inline-block;
			height: 100%;
			vertical-align: middle;
			content: '';
			margin-right: -0.25em;
		}
		.centered{
			display: inline-block;
			vertical-align: center;
			 50%;
		}
		    
<div class="block" style="height: 300px;">
	    <div class="centered">
	        <h1>haorooms案例题目</h1>
	        <p>haorooms案例内容,haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容</p>
	        <p>haorooms案例内容,haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容</p>
	        <p>haorooms案例内容,haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容haorooms案例内容</p>
	    </div>
	</div>
<table style=" 100%; height: 300px;background: blue;">
	  <tr>
	     <td style="text-align: center; vertical-align: middle;">
	          Unknown stuff to be centered.
	     </td>
	  </tr>
	</table>
原文地址:https://www.cnblogs.com/caijw/p/8024726.html