CSS学习(三)-css边框样式(上)

一、理论:

1.css边框简介
a.border-width 设置粗细
b.border-color 设置颜色
c.border-style 设置类型
d.以上都遵守TRBL原则,例:border-top-style
2.边框的类型
a.none 无边框
b.hidden 无边框,但对于表而言是解决边框冲突
c.dotted 点状边框
d.dashed 虚线边框
e.solid 实线边框
f.double 双线边框
g.groove 凹槽边框
h.ridge 垄状边框
i.inset 3d inset边框
j.outset 3d outset边框
k.inherit 从父元素继承边框样式,但只有某些浏览器支持此属性
3.不同浏览器前缀:
a.-moz- firefox
b.-o- Opera
c.-khtml-  Konqueror
d.-ms- Internet Explorer
e.插件-prefix-free 可略去浏览器前缀
4.border-image属性语法及参数:
a.none 无背景
b.image 背景图片
c.<number> 表示方位
d.<precentage> 设置边框背景图片大小(百分比)
e.stretch\repeat\round 拉伸\重复\平铺边框背景

二、实践:

1.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        .border-image{
            background-color: #6bb2ff;
            width:150px;
            height: 100px;
            border: 27px solid;
            -webkit-border-image: url(images/border.jpg) 27 round stretch;
            -moz-border-image: url( images/border.jpg) 27 round stretch;
            -o-border-image: url( images/border.jpg) 27 round stretch;
            -ms-border-image: url( images/border.jpg) 27 round stretch;
        }
        .border-image-repeat{
            background-color: #6bb2ff;
            width:150px;
            height: 100px;
            border: 27px solid;
            -webkit-border-image: url(images/border.jpg) 27 repeat stretch;
            -moz-border-image: url( images/border.jpg) 27 repeat stretch;
            -o-border-image: url( images/border.jpg) 27 repeat stretch;
            -ms-border-image: url( images/border.jpg) 27 repeat stretch;
        }
        .border-image-stretch{
            background-color: #6bb2ff;
            width:150px;
            height: 100px;
            border: 27px solid;
            -webkit-border-image: url(images/border.jpg) 27 stretch stretch;
            -moz-border-image: url( images/border.jpg) 27 stretch stretch;
            -o-border-image: url( images/border.jpg) 27 stretch stretch;
            -ms-border-image: url( images/border.jpg) 27 stretch stretch;
        }

    </style>
</head>
<body>
    <div class="border-image"></div>
    <div class="border-image-repeat"></div>
    <div class="border-image-stretch"></div>
</body>
</html>
2.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        .border-image{
            background-color: #6bb2ff;
            width:150px;
            height: 100px;
            border: 27px solid;
            -webkit-border-image: url(images/border.jpg) 27 stretch round ;
            -moz-border-image: url( images/border.jpg) 27 stretch round ;
            -o-border-image: url( images/border.jpg) 27 stretch round ;
            -ms-border-image: url( images/border.jpg) 27 stretch round ;
        }
        .border-image-repeat{
            background-color: #6bb2ff;
            width:150px;
            height: 100px;
            border: 27px solid;
            -webkit-border-image: url(images/border.jpg) 27 stretch repeat;
            -moz-border-image: url( images/border.jpg) 27 stretch repeat;
            -o-border-image: url( images/border.jpg) 27 stretch repeat;
            -ms-border-image: url( images/border.jpg) 27 stretch repeat;
        }
    </style>
</head>
<body>
    <div class="border-image"></div>
    <div class="border-image-repeat"></div>
</body>
</html>



你可能感兴趣的:(css,css3)