网页中用CSS做虚线

html-css011

网页中用CSS做虚线,第1张

<td

style="border-bottom:1px

dotted

#ccc">文字内容</td>

<td

style="border(边框)-bottom(底部):1px(1像素)

dotted

(虚线)#ccc(颜色)">文字内容</td>

上面这句话的意思是:在这个td里面的样式为

底部边框为1像素颜色为#ccc的虚线

dotted

是虚线

solid

是实线

<!DOCTYPE HTML>

<html>

<meta charset="UTF-8" />

<head>

<title></title>

</head>

<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>

<style type="text/css">

*{

margin: 0

padding: 0

}

.box {width: 100%border: 1px solid #000000box-sizing: border-boxposition: relative}

.img1{height: 100%width: 100%}

li{list-style: none}

.box li{border-bottom: 1px dashed #000000width: 80%background: #DCDCDCheight: 35px}/*dashed是虚线width控制li的宽度*/

.text{position: absolutetop:42.5pxleft:30%}

.text20{position: absolutetop:42.5pxright:20px}

</style>

<body>

<div class="demo">

<div class="box" style="">

<ul>

<li>内容1</li>

<li>内容2</li>

<li>内容3</li>

</ul>

<div class="text">

灰色内容占总宽度80%

</div>

<div class="text20">

白色内容占</br>总宽度20%

</div>

</div>

</div>

</body>

</html>

直接运用CSS中的文本修饰属性text-decoration是没有办法实现下划线为虚线的。不过可以考虑使用border属性来实现。示例代码如下:

border-bottom:1px dashed #000

这里的意思就是1px宽度的黑色虚线下边框。看起来就跟下划线一样的效果。