欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

CSS兩種水平垂直居中示例介紹

  發(fā)布時間:2013-09-16 15:12:46   作者:佚名   我要評論
水平垂直居中在css中的應用想必大家已經(jīng)很熟悉。盡管如此,在本文也要為大家介紹兩種不錯的實現(xiàn)方法,如果你想鞏固一下,那還是值得一看的
第一種:將固定大小的div框相對窗口水平垂直居中,改變?yōu)g覽器窗口大小時,依然保持水平垂直居中;

復制代碼
代碼如下:

<!doctype html>
<html lang="en">
<head>
<title>水平垂直居中</title>
<meta charset="utf-8">
<style type="text/css">
.out{width: 0px;
height: 0px;
position: absolute;
left: 50%;
top: 50%;
}
.in{height: 300px;
width: 300px;
position: absolute;
left: -150px;
top: -150px;
background-color: #999;
}
</style>
</head>
<body>
<div class="out">
<div class="in"></div>
</div>
</body>
</html>

 
第二種:讓一個自適應大小的div相對瀏覽器窗口水平垂直居中

復制代碼
代碼如下:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>自適應劇中</title>
<style type="text/css">
.middle{
height: 300px;
width: 300px;
border: 1px solid;
display: table-cell;
text-align: center;
vertical-align: middle;
}
.in{
background-color: red;
height: auto;
width: auto;
min-width: 0px;
min-height: 0px;
display: inline;
}
</style>
</head>
<body>
<div class="middle">
<div class="in">內(nèi)容自適應水平垂直居中</div>
</div>
</body>
</html>

相關文章

最新評論