css中虚线长度的设置

html-css042

css中虚线长度的设置,第1张

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

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

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

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

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

在CSS 中常见的边框(border) 属性有以下几种:

border-style

border-width

border-color

border-top-, border-left-, border-bottom-, border-right-

border

border-style

border-style属性指定边框的样式。以下的表格列出这个属性可能有的值,以及每一个值显现出来的结果。

border-width

border-width属性是用来设定边框的宽度。可用的值为thin (薄)、medium (中等)、thick (厚),或是一个数字。

border-color

border-color属性是用来设定边宽的颜色。

border-top-, border-left-, border-bottom-, border-right-

我们可以将方向(top -上、bottom -下、left -左、right -右)和样式、宽度、及颜色合起来而成为一个属性。举例来说, border-top-style属性就是用来设定上边框的样式。以下举几个例子:

border

若四边的边框属性都一样,那我们可以用一个border属性来描述,而不必四个边都描述一次。另外,我们可以在同一行一次宣告边框样式、边框宽度、以及边框颜色。

p {

border:#0000FF 5px solid 

}

那以下的HTML,

<p>用一行来宣布所有边框的属性</p> 

会显现出