CSS如何定义一条水平虚线?

html-css0212

CSS如何定义一条水平虚线?,第1张

需要准备的材料分别有:电脑、浏览器、html编辑器。

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html中的<style>标签中,输入css代码:div {height:60pxborder-bottom:1px dashed}。

3、浏览器运行index.html页面,此时通过css定义了一个水平的虚线。

<!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>