css border-left设置左边框

时间:2016-07-16
css border-left属性用于设置html元素左边框,左边框包括左边框宽度border-left-width、左边框样式类型border-left-style和左边框颜色border-left-color。本文章向大家介绍css border-left使用方法和实例,需要的朋友可以参考一下。

border-left简介

css border-left属性用于设置html元素左边框,可以设置的属性是:

  1. border-left-width 左边框的宽度
  2. border-left-style 左边框的样式类型
  3. border-left-color 左边框的颜色

比如现在有这样一个CSS样式:

border-left-width:1px;
border-left-style:solid;
border-left-color:red;

我们可有直接使用border-left这一个属性来声明上面三个属性:

border-left:1px solid red;

属性值依次是border-left-width, border-left-style,border-left-color. 

如果上述值缺少一个也没关系,例如border-left:solid #ff0000; 是允许的。

但是如果将border-left-style设置为none,那么就算其他边框属性被设置值,也不会取到任何作用。例如:

border-left:1px none red;

上面这个css代码相当于没有设置左边框,因为border-left-style设置为none;其他边框属性也就不取作用了。

border-left实例

css border-left设置左边框的样式:

<!DOCTYPE html>
<html>
<head>
<title>http://www.manongjc.com/article/1196.html</title>
<style>
p{
    border-style:solid;
    border-left:thick double #ff0000;
}
</style>
</head>
<body>
<p>This is some text in a paragraph.</p>
</body>
</html>

在线运行