首页
产品
快图
小程序
微商城
网站建设
新闻
公司动态
行业资讯
关于
案例
联系
css实例教程:DIV竖直垂直居中的方法
2021-01-20 16:39
jianzhan
历经今日1翻改善,终究找出掌握决DIV竖直垂直居中的方法。
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf⑻" />
<title>CSS合理布局技能:未知高宽比div 竖直垂直居中的难题</title>
<style type="text/css">
html,body
{
height: 100%;
padding:0;
margin:0;
}
body
{
min-height: 200px;
text-align: center;
min-width: 402px
}
.FirstDIV
{
margin-top: ⑴00px; /* SecondDIV高宽比的1半 */
float: left;
width: 100%;
height: 50%;
}
.SecondDIV
{
clear: both;
border: silver 1px solid;
background: #666;
margin-left: auto;
overflow: auto;
width: 400px;
margin-right: auto;
height: 200px;
text-align: left
}
</style>
</head>
<body>
<div class="FirstDIV"></div>
<div class="SecondDIV">
<p>看看,这不就垂直居中了。呵呵。并且沒有难题哦。www.Webjx.com </p>
<p>body{ background-color:#FFF5F0}<br>
div{ position:absolute; top:50%; left:50%; margin:⑴00px 0 0 ⑵00px;
width:400px; height:200px; border:1px #CCCC00 solid; font-family:Arial,
Helvetica, sans-serif; color:#666666 } </p>
</div>
</body>
</html>
演试编码:
<!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> <meta http-equiv="Content-Type" content="text/html; charset=utf⑻" /> <title>CSS合理布局技能:未知高宽比div 竖直垂直居中的难题</title> <style type="text/css"> html, body { height: 100%; padding:0; margin:0; } body { min-height: 200px; text-align: center; min-width: 402px } .FirstDIV { margin-top: ⑴00px; /* SecondDIV高宽比的1半 */ float: left; width: 100%; height: 50%; } .SecondDIV { clear: both; border: silver 1px solid; background: #666; margin-left: auto; overflow: auto; width: 400px; margin-right: auto; height: 200px; text-align: left } </style> </head> <body> <div class="FirstDIV"></div> <div class="SecondDIV"> <p>看看,这不就垂直居中了。呵呵。并且沒有难题哦。www.Webjx.com </p> <p>body{ background-color:#FFF5F0}<br> div{ position:absolute; top:50%; left:50%; margin:⑴00px 0 0 ⑵00px; width:400px; height:200px; border:1px #CCCC00 solid; font-family:Arial, Helvetica, sans-serif; color:#666666 } </p> </div> </body> </html>
[Ctrl A 所有挑选 提醒:你可先改动一部分编码,再按运作]
为您推荐
css实例教程:DIV竖直垂直居中的方法
CSS实例教程:完全弄懂闭合波动元素
相对性完善的CSS肯定底部
CSS Border特性制做小3角
CSS 情况全功略
所有文章
公司动态
行业资讯