CSS布局(二)
CSS经典布局案例(二):
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>CSS布局</title> </head> <body> <div style="background-color: chartreuse; height: 150px"></div> <div style="background-color: red; width: 200px;height: 400px;float: left"></div> <div style="background-color: yellow;height: 300px;overflow: hidden"> <div style="background-color: blue;height: 300px;width: 200px;float: right"></div> </div> <div style="background-color: gray;height: 150px;clear: both"></div> </body> </html>
上述代码定义了五个div块,用到了float浮动属性、overflow属性和clear属性;其中用到了div块的嵌套。
页面效果如下:
其中红色和蓝色div块为定宽绿色、黄色和灰色不定宽。
相关推荐
qiupu 2020-11-04
多读书读好书 2020-11-03
RedCode 2020-10-28
jiedinghui 2020-10-25
Ladyseven 2020-10-22
hellowzm 2020-10-12
zuncle 2020-09-28
Ladyseven 2020-09-11
jiedinghui 2020-09-07
xiaohuli 2020-09-02
葉無聞 2020-09-01
impress 2020-08-26
ThikHome 2020-08-24
nicepainkiller 2020-08-20
hellowzm 2020-08-18