DIV+CSS一行三列代码如何写?

html-css012

DIV+CSS一行三列代码如何写?,第1张

此处的注释为去掉换行符的影响

.wrapper

{

width:

100%

/*

也可以固定宽度

*/

height:

200px

}

.wrapper

>

div

{

display:

inline-block

/*

如需支持ie8以下版本,用浮动来做

*/

width:

calc(100%

/

3)

/*

此处运用了一个css3的表达式,将div三等分,ie8及以上可以支持,当然也可以根据需要设置固定值

*/

width:

-webkit-calc(100%

/3)

width:

-moz-calc(100%

/

3)

height:

100%

}

以上经亲自测过,ie8+、chrome、firefox表现良好。

1行3列实现代码

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>景安</title>

<style type="text/css">

.zzidc{width: 500pxheight: 300pxbackground: red}

.a{float: leftwidth: 200pxheight: 300pxbackground: blue}

.b{float: leftwidth: 100pxheight: 300pxbackground: green}

.c{float: leftwidth: 200pxheight: 300pxbackground: gray}

</style>

</head>

<body>

<div class="zzidc">

<div class="a"></div>

<div class="b"></div>

<div class="c"></div>

</div>

</body>

</html>

1列多行实现代码

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>景安</title>

<style type="text/css">

.a{width: 300pxheight: 50pxbackground: blue}

.b{width: 300pxheight: 50pxbackground: green}

.c{width: 300pxheight: 50pxbackground: gray}

</style>

</head>

<body>

<div class="a"></div>

<div class="b"></div>

<div class="c"></div>

</div>

</body>

</html>

实现一行3列的话可以使用浮动布局或者定位,实现一列多行的使用使用默认布局模式即可