首頁  >  文章  >  web前端  >  多行文本在固定高度容量下的居中_html/css_WEB-ITnose

多行文本在固定高度容量下的居中_html/css_WEB-ITnose

WBOY
WBOY原創
2016-06-24 11:25:38988瀏覽

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">  <head>  <title> 多行文字实现垂直居中 </title>  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  <style type="text/css">body { font-size:12px;font-family:tahoma;}div#wrap {display:table;border:1px solid #FF0099;background-color:#FFCCFF;width:760px;height:400px;*position:relative;/*hack IE6和IE7*/overflow:hidden;}div#subwrap { vertical-align:middle;display:table-cell;*position:absolute;/*hack IE6和IE7*/*top:50%;/*hack IE6和IE7*/}div#content { border:1px solid #000; *position:relative;/*hack IE6和IE7*/ *top:-50%;/*hack IE6和IE7*/}  </style>  </head>  <body>  <div id="wrap">  <div id="subwrap">  <div id="content">现在我们要使这段文字垂直居中显示!</div>  </div>  </div>  </body></html>

  

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn