Css 对中主分区
我有一个div,里面是其他div。我的div是:Css 对中主分区,css,Css,我有一个div,里面是其他div。我的div是: 如何将其居中,以便所有其他div都居中 margin-left: auto; margin-right: auto; 并且确保它没有100%的宽度 --编辑: 因为您使用的是位置:绝对具有已知宽度(本例中为900px),您可以执行以下操作: left: 50%; margin-left: -450px; 其中-450px为宽度的一半,取反 并且确保它没有100%的宽度 --编辑: 因为您使用的是位置:绝对具有已知宽度(本例中为900px),您
如何将其居中,以便所有其他div都居中
margin-left: auto;
margin-right: auto;
并且确保它没有100%的宽度
--编辑:
因为您使用的是位置:绝对代码>具有已知宽度(本例中为900px
),您可以执行以下操作:
left: 50%;
margin-left: -450px;
其中-450px
为宽度的一半,取反
并且确保它没有100%的宽度
--编辑:
因为您使用的是位置:绝对代码>具有已知宽度(本例中为900px
),您可以执行以下操作:
left: 50%;
margin-left: -450px;
其中-450px
为宽度的一半,取反。内部{margin:0 auto;}
要使其垂直居中,请执行以下操作:
inner_div { position:absolute; top:50%; margin-top:-300px; }
internal_div{margin:0 auto;}
要使其垂直居中,请执行以下操作:
inner_div { position:absolute; top:50%; margin-top:-300px; }
这是我的css:
#Table_01 {
position:absolute;
left:0px;
top:0px;
width:900px;
height:600px;
}
#index-01 {
position:absolute;
background-color:#003366;
left:0px;
top:0px;
width:900px;
height:30px;
}
#index-02 {
position:absolute;
left:0px;
top:30px;
width:900px;
height:72px;
}
#index-03 {
position:absolute;
left:0px;
top:102px;
width:900px;
height:27px;
}
#index-04 {
position:absolute;
left:0px;
top:129px;
width:223px;
height:223px;
}
#index-05 {
position:absolute;
left:223px;
top:129px;
width:382px;
height:174px;
}
#index-06 {
position:absolute;
left:605px;
top:129px;
width:295px;
height:223px;
}
#index-07 {
position:absolute;
left:223px;
top:303px;
width:382px;
height:49px;
}
#index-08 {
position:absolute;
left:0px;
top:352px;
width:475px;
height:183px;
}
#index-09 {
position:absolute;
left:475px;
top:352px;
width:425px;
height:183px;
}
#index-10 {
position:absolute;
left:0px;
top:535px;
width:900px;
height:34px;
}
#index-11 {
position:absolute;
background-color:#003366;
left:0px;
top:569px;
width:900px;
height:31px;
}
我的html:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="http://localhost/assets/css/td.css" />
<title>Training Day</title>
<body style="margin: 0px; background-color: rgb(255, 255, 255);">
<div id="Table_01">
<div id="index-01"> $today is<br>
</div>
<div id="index-02">
$logo and
$searchbox<br>
</div>
<div id="index-03">
Navigation<br>
</div>
<div id="index-04">
Box 1<br>
</div>
<div id="index-05">
Front page picture holder<br>
</div>
<div id="index-06"> Trending Topics<br>
</div>
<div id="index-07"> Heading author and location</div>
<div id="index-08">
Tabs<br>
</div>
<div id="index-09">
Twitter Live Feeds<br>
</div>
<div id="index-10">
Stats bar<br>
</div>
<div id="index-11">
Footer<br>
</div>
</div>
<!-- End Save for Web Slices -->
</body>
</html>
训练日
$today是
$logo和
$searchbox
导航
框1
头版图片夹
趋势主题
标题作者和位置
选项卡
Twitter实时订阅源
统计栏
页脚
这是我的css:
#Table_01 {
position:absolute;
left:0px;
top:0px;
width:900px;
height:600px;
}
#index-01 {
position:absolute;
background-color:#003366;
left:0px;
top:0px;
width:900px;
height:30px;
}
#index-02 {
position:absolute;
left:0px;
top:30px;
width:900px;
height:72px;
}
#index-03 {
position:absolute;
left:0px;
top:102px;
width:900px;
height:27px;
}
#index-04 {
position:absolute;
left:0px;
top:129px;
width:223px;
height:223px;
}
#index-05 {
position:absolute;
left:223px;
top:129px;
width:382px;
height:174px;
}
#index-06 {
position:absolute;
left:605px;
top:129px;
width:295px;
height:223px;
}
#index-07 {
position:absolute;
left:223px;
top:303px;
width:382px;
height:49px;
}
#index-08 {
position:absolute;
left:0px;
top:352px;
width:475px;
height:183px;
}
#index-09 {
position:absolute;
left:475px;
top:352px;
width:425px;
height:183px;
}
#index-10 {
position:absolute;
left:0px;
top:535px;
width:900px;
height:34px;
}
#index-11 {
position:absolute;
background-color:#003366;
left:0px;
top:569px;
width:900px;
height:31px;
}
我的html:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="http://localhost/assets/css/td.css" />
<title>Training Day</title>
<body style="margin: 0px; background-color: rgb(255, 255, 255);">
<div id="Table_01">
<div id="index-01"> $today is<br>
</div>
<div id="index-02">
$logo and
$searchbox<br>
</div>
<div id="index-03">
Navigation<br>
</div>
<div id="index-04">
Box 1<br>
</div>
<div id="index-05">
Front page picture holder<br>
</div>
<div id="index-06"> Trending Topics<br>
</div>
<div id="index-07"> Heading author and location</div>
<div id="index-08">
Tabs<br>
</div>
<div id="index-09">
Twitter Live Feeds<br>
</div>
<div id="index-10">
Stats bar<br>
</div>
<div id="index-11">
Footer<br>
</div>
</div>
<!-- End Save for Web Slices -->
</body>
</html>
训练日
$today是
$logo和
$searchbox
导航
框1
头版图片夹
趋势主题
标题作者和位置
选项卡
Twitter实时订阅源
统计栏
页脚
应该可以:
表01{
}应该可以:
表01{
}这对我来说总是有效的
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl">
<head>
<style type="text/css">
body {
text-align: center;
}
#mainsite {
width: 770px;
margin: auto;
text-align: left;
background-color: red;
}
</style>
</head>
<body>
<div id="mainsite">
whee
</div>
</body>
</html>
身体{
文本对齐:居中;
}
#主站点{
宽度:770px;
保证金:自动;
文本对齐:左对齐;
背景色:红色;
}
惠伊
这对我来说总是有效的
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl" lang="nl">
<head>
<style type="text/css">
body {
text-align: center;
}
#mainsite {
width: 770px;
margin: auto;
text-align: left;
background-color: red;
}
</style>
</head>
<body>
<div id="mainsite">
whee
</div>
</body>
</html>
身体{
文本对齐:居中;
}
#主站点{
宽度:770px;
保证金:自动;
文本对齐:左对齐;
背景色:红色;
}
惠伊
#Table_01{位置:绝对;左侧:0px;顶部:0px;宽度:900px;高度:600px;}如果您使用已知宽度执行位置:绝对
操作,您可以执行类似左侧:50%;左边距:-450px代码>#表01{位置:绝对;左:0px;顶部:0px;宽度:900px;高度:600px;}如果你用已知宽度做位置:绝对
,你可以做类似左:50%;左边距:-450px代码>是否将其设置为内部div?是否将其设置为内部div?