这是今天有人发邮件问的一个问题,最开始的想法是用ul列表来实现;但是这样用出现两个比较麻烦的地方:
1、如果用UL还布局,右边一栏比较麻烦;
2、文字外边的边框自适应比较麻烦;
3、很可能要定死高度;
所以,细细地看一看这个布局,想一想还是用DL.DT.DD作是合理的:
1、布局合理一些;
2、将来扩展很方便;
3、CSS一定很少;
试着写了写,看一看还行!在可控范围内!
布局布分当然不用说了:
标题
CSS部分:
*{ margin:0; padding:0;}
body{ font-size:12px; line-height:1.8; padding:10px;}
dl{clear:both; margin-bottom:5px;float:left;}
dt,dd{padding:2px 5px;float:left; border:1px solid #3366FF}
dd{ position:absolute; right:5px;}
h1{clear:both;font-size:14px;}
看一下效果:
*{ margin:0; padding:0;}
body{ font-size:12px; line-height:1.8; padding:10px;}
dl{clear:both; margin-bottom:5px;float:left;}
dt,dd{padding:2px 5px;float:left; border:1px solid #3366FF}
dd{ position:absolute; right:5px;}
h1{clear:both;font-size:14px;}
test
test
如果说定宽?
*{ margin:0; padding:0;}
body{ font-size:12px; line-height:1.8; padding:10px;}
dl{clear:both; margin-bottom:5px;float:left;width:100%}
dt,dd{padding:2px 5px;float:left; border:1px solid #3366FF}
dd{ float:right}
h1{clear:both;font-size:14px;}
div{ width:500px; float:left;}
标题
-
·博客里的文章是我自己写的!
- 作者:张三
-
·博客里的文章是我自己写的!
- 作者:张三
-
·博客里的文章是我自己写的!
- 作者:张三
-
·博客里的文章是我自己写的!
- 作者:张三
-
·博客里的文章是我自己写的!
- xxx
-
·博客里的文章是我自己写的!
- xxx
-
·博客里的文章是我自己写的!
- xxx
标题
-
·博客里的文章是我自己写的!
- xxx
-
·博客里的文章是我自己写的!
- xxx
-
·博客里的文章是我自己写的!
- xxx
-
·博客里的文章是我自己写的!
- xxx
-
·博客里的文章是我自己写的!
- xxx
-
·博客里的文章是我自己写的!
- xxx
-
·博客里的文章是我自己写的!
- xxx
相关的例子,我以前也写过一个:
*{ margin:0; padding:0;}
#box{ margin:10px; padding:10px; float:left; border:1px solid #CCC; background:#FFFFCC; font-size:12px; line-height:1.9;}
dl{ background:#CCCC00; margin:0; width:120px; text-align:center; float:left; margin:5px;}
dt{ background:#CC0033;}dt img{display:block; margin:0 auto;}
dd{ background:#FFFF00; }
- 母亲节-祝福短信
- 母亲节-祝福短信
- 母亲节-祝福短信
- 母亲节-祝福短信
- 母亲节-祝福短信
本文原创发布php中文网,转载请注明出处,感谢您的尊重!