本人菜鸟刚学DIV+CSS,求解这种布局怎么写?尤其是倒数第二行四个矩形

一种方法是用浮动布局,另一种是用绝对定位布局。以下是浮动方法:float布局.html 文件代码清单如下: float布局
本人菜鸟刚学DIV+CSS,求解这种布局怎么写?尤其是倒数第二行四个矩形
一种方法是用浮动布局,另一种是用绝对定位布局。以下是浮动方法:
float布局.html 文件代码清单如下:
<!doctype html><html lang="zh"> <head> <meta charset="utf-8"> <title>float布局</title> <link rel="stylesheet" href="floatdiv.css"> </head> <body> <div id="wrapper"> <div id="div1" class="one"></div> <div id="div2" class="one"></div> <div id="div3" class="one"></div> <div id="div4"></div> <div id="div5" class="two"></div> <div id="div6" class="two"></div> <div id="div7" class="two"></div> <div id="div8" class="two"></div> <div id="div9"></div> </div> </body></html>floatdiv.css 文件代码清单如下:
/* floatdiv.css */#wrapper {width: 100%;}div {margin-bottom: 2%;height: 100px;}.one {height: 200px;}#div1 {float: left;width: 38%;background: #990100;}#div2 {float: left;margin-right: 2%;margin-left: 2%;width: 29%;background: #3399fe;}#div3 {float: right;width: 29%;background: #00ff01;}#div4 {clear: both;width: 100%;background: #0000fe;}.two {float: left;}#div5 {margin-right: 2%;width: 18%;background: #999965;}#div6 {margin-right: 2%;width: 18%;background: #99fe00;}#div7 {margin-right: 2%;width: 29%;background: #0ff;}#div8 {float: right;width: 29%;background: #ccc;}#div9 {clear: both;width: 100%;height: 80px;background: #000;}对于ie的很多版本而言,以上CSS的代码需要调整宽度,使每行的宽度小于100%,这样就行。
2013-11-08
倒数第二行和第一行一个道理啊,像一楼兄弟说的,给div一个float属性,控制宽度就可以。颜色当然用填充啊,默认是白色的。2013-11-08
<style type="text/css">
.bdy{width:960px; height:860px;}
.top{margin:10px 0px; width:960px; height:100px;}
.item1{float:left; margin-right:10px; width:450px; height:100px; background-color:#CCC}
.item2{float:left; margin-right:10px; width:240px; height:100px; background-color:#CCC}
.middle{margin:10px 0px; width:950px; height:100px;}
.mid{float:left; margin-right:10px; width:950px; height:100px; background-color:#CCC}
.bottom{float:left; margin-right:10px; width:230px; height:100px; background-color:#CCC}
.foot{float:left; margin-right:10px; width:950px; height:120px; background-color:#CCC}
</style>

<body>
<div class="bdy">
<div class="top">
<div class="item1"></div>
<div class="item2"></div>
<div class="item2"></div>
</div>
<div class="middle">
<div class="mid"></div>
</div>
<div class="top">
<div class="bottom"></div>
<div class="bottom"></div>
<div class="bottom"></div>
<div class="bottom"></div></div>
<div class="middle">
<div class="foot"></div>
</div>
</div>
</body>

希望对你有帮助2013-11-08
用盒子的浮动属性就能很好的解决2013-11-08
mengvlog 阅读 7 次 更新于 2025-07-20 10:03:14 我来答关注问题0
  •  xiajie30 DIV+CSS,本人菜鸟,刚开始学,很多不懂请教一个弱智的问题谢谢!

    2010元月25至31日 中的是你自定义的。其实在HTML这是不规范的。不可以自己定义。至于添加样式可以这样:2010元月25至31日 p{font-size=50px;color:red;background-color:blue;}.p1{font-size=30px;color:red;background-color:green;}...

  •  jy07sg div+css布局 我是菜鸟 请教高手

    下左 下中 下右 底部 这是初步的排布,具体的还是得你自己去熟悉下

  •  短髮丫頭 DIV+CSS如何实现一行文字显示不下的自动隐藏!虽然是很菜鸟的问题但还是希望大神们帮帮忙哈!下面有截图

    .top_right_nav{ overflow:hidden;}把高度设置成一个数值,再加上一个超出部分隐藏,就行了height:*px;overflow:hidden;给 包裹 div 加个css属性 overflow:hidden;设置.top_right_nav{width:100%;height:40px; overflow:hidden;}overflow:hidden;设置高度,然后overflow:hidden;

  •  百度网友58d3f0f 菜鸟如何学好网页div+css?

    搞懂基本属性 然后就是模仿了 多分析别的页面的结构设置什么的 学以致用 书上得来终觉浅,要想学会得躬行。

  •  shewa5337 【高分】DIV CSS一系列问题(高手进)

    基于web标准(standards-based presentation)XHTML+CSS的表示; 使用DOM(Document Object Model)进行动态显示及交互; 使用XML 和 XSLT 进行数据交换及相关操作; 使用XMLHttpRequest 进行异步数据查询、检索; 使用JavaScript 将所有的东西绑定在一起。英文参见Ajax的提出者Jesse James Garrett的原文,原文题目(Ajax: A New ...

檬味博客在线解答立即免费咨询

CSS相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部