本篇文章给大家带来的内容是关于border-image属性如何使用?border-image属性教程详解,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。

在CSS入门教程中,我们学习了边框样式border-style,其中边框只有实线、虚线、点状线等几种简陋的形式。那假如我们想要为边框添加漂亮的背景图片,那该怎么做呢?

在CSS3中,我们可以使用border-image属性为边框添加背景图片。

说明:

从语法分析,我们可以看出,使用border-image属性设置边框背景图片需要设置3种参数:

(1)图片路径;

(2)切割图片的宽度(4条边的宽度,依次为上边、右边、下边、左边,按照顺时针方向,类似于border属性的4条边顺序);

(3)图片平铺方式;

假如我们要把下面这张图作为(90px×90px)元素边框的背景图片,应该怎么做呢?(下面每个小方块30px×30px)

举例:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>CSS3 border-image属性</title>
    <style type="text/css">
    #div1
    {
        width:210px;
        height:150px;
        border:30px solid gray;
        border-image:url("../App_images/lesson/run_css3/border_img1.png") 30 repeat;
        -webkit-border-image:url("../App_images/lesson/run_css3/border_img1.png") 30 repeat;
        -moz-border-image:url("../App_images/lesson/run_css3/border_img1.png") 30 repeat;
    }
    </style>
</head>
<body>
    <div id="div1">
    </div>
</body>
</html>
登录后复制

border-image属性如何使用?border-image属性教程详解-LMLPHP

本篇文章给大家带来的内容是关于border-image属性如何使用?border-image属性教程详解,如果您想了解更多有关CSS3视频教程,请关注Work网。


以上就是border-image属性如何使用?border-image属性教程详解的详细内容,更多请关注Work网其它相关文章!

09-19 12:21