怎样用CSS将着四个div实现同一条线,水平居中?代码如下:<html><head><title></title><style type="text/css">.one{border:2px solid red;width:250px;height:50px;text-align:center;background:#999;
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 20:01:23
怎样用CSS将着四个div实现同一条线,水平居中?代码如下:<html><head><title></title><style type="text/css">.one{border:2px solid red;width:250px;height:50px;text-align:center;background:#999;
怎样用CSS将着四个div实现同一条线,水平居中?
代码如下:
<html>
<head>
<title></title>
<style type="text/css">
.one{
border:2px solid red;
width:250px;
height:50px;
text-align:center;
background:#999;
float:left;}
.two{
border:2px solid red;
width:250px;
height:50px;
text-align:center;
background:#066;
float:left;}
.three{
border:2px solid red;
width:250px;
height:50px;
text-align:center;
background:#C90;
float:left;}
.four{
border:2px solid red;
width:250px;
height:50px;
text-align:center;
background:#F6F;float:left;}
</style>
</head>
<body>
<div class="one">one</div>
<div class="two">two</div>
<div class="three">three</div>
<div class="four">four</div>
</body>
</html>
怎样用CSS将着四个div实现同一条线,水平居中?代码如下:<html><head><title></title><style type="text/css">.one{border:2px solid red;width:250px;height:50px;text-align:center;background:#999;
设置它们的父级,如body:text-align:center;
给它们一个包含框如div,并设置:width、margin:0 auto;
<div id="d1">
<div class="i">one</div>
<div class="i">two</div>
<div class="i">three</div>
<div class="i">four</div>
</div>
#d1{text-align:center;}
.i{display:inline;margin: 0 auto; }