- 相干保举
html元素程度常中的方式
html元素有哪些?程度常中于其父级元素的方式你是不是晓得呢?就让小编来告知你们哦!
方式1:
代码以下:
<p class="wrap">
<p class="left-right-middle1">摆布居中方式1</p>
</p>
代码以下:
html,body,p{
margin:0;
padding:0;
height:100%;
position:relative;
}
.wrap{
width:400px;
height:300px;
margin:10px;
border:1px solid #000;
}
.left-right-middle1{
width:200px;
background-color:#69F;
margin:0 auto;
}
方式2:
代码以下:
<p class="wrap">
<p class="left-right-middle2">摆布居中方式2</p>
</p>
代码以下:
html,body,p{
margin:0;
padding:0;
height:100%;
position:relative;
}
.wrap{
width:400px;
height:300px;
margin:10px;
border:1px solid #000;
}
.left-right-middle2{
width:200px;
background-color:#69F;
left:50%;
margin-left:-100px;
}
html元素 垂直居中 于 其父级元素的方式:
代码以下:
<p class="wrap">
<p class="top-bottom-middle">高低居中</p>
</p>
代码以下:
html,body,p{
margin:0;
padding:0;
height:100%;
position:relative;
}
.wrap{
width:400px;
height:300px;
margin:10px;
border:1px solid #000;
}
.top-bottom-middle{
height:200px;
background-color:#69F;
top:50%;
margin-top:-100px;
}
html元素 程度垂直居中 于 其父级元素的方式:
方式1:
代码以下:
<p class="wrap">
<p class="all-middle1">高低摆布居中方式1</p>
</p>
代码以下:
html,body,p{
margin:0;
padding:0;
height:100%;
position:relative;
}
.wrap{
width:400px;
height:300px;
margin:10px;
border:1px solid #000;
}
.all-middle1{
width:200px;
height:200px;
background-color:#69F;
top:50%;
margin:-100px auto 0;
}
方式2:
代码以下:
<p class="wrap">
<p class="all-middle2">高低摆布居中方式2</p>
</p>
代码以下:
html,body,p{
margin:0;
padding:0;
height:100%;
position:relative;
}
.wrap{
width:400px;
height:300px;
margin:10px;
border:1px solid #000;
}
.all-middle2{
width:200px;
height:200px;
background-color:#69F;
top:50%;
left:50%;
margin:-100px 0 0 -100px;
}
完全代码:
代码以下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="//www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
<title>p Middle</title>
<style type="text/css">
html,body,p{
margin:0;
padding:0;
height:100%;
position:relative;
}
.wrap{
width:400px;
height:300px;
margin:10px;
border:1px solid #000;
}
.left-right-middle1{
width:200px;
background-color:#69F;
margin:0 auto;
}
.left-right-middle2{
width:200px;
background-color:#69F;
left:50%;
margin-left:-100px;
【html元素程度常中的方式】相干文章:
CSS 若何使p层程度常中03-29
html5的canvas方式利用03-02
进步英语浏览程度的方式12-07
HTML5字体设置的方式03-29
报检员程度测试温习方式03-16
程度的方式进步英语听力12-04
进步英语听力程度的方式03-28
进步英语听力程度的方式03-25
进步英语听力程度的方式先容02-03