温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

在css中实现多色边框,border-colors属性的方法

发布时间:2020-08-31 14:36:59 来源:亿速云 阅读:359 作者:小新 栏目:web开发

这篇文章主要介绍在css中实现多色边框,border-colors属性的方法,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

在css3中,我们可以用border-colors来制作多颜色的边框,但是也有很多人总把border-color和border-colors弄混淆,我们这里用到的是border-colors,并不是border-color。

border-colors语法:

-moz-border-left-colors:颜色值;对于border-colors属性,我们要注意三点:

1.如果border-width为w像素,就表示边框可以几种颜色,但是前提每种颜色都是颜色限制唯一的宽度。

2.因为border-colors并不能所有的浏览器都是使用,因此我们在代码前面加一个-moz-。

3.我们不能同时设置四条边颜色,但是我们可以分为四段颜色为四条边的设置。

实例:

<!DOCTYPE html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>CSS3 border-colors属性</title>
    <style type="text/css">
    #div1
    {
        width:200px;
        height:100px;
        border-width:5px;
        border-style:solid;
        -moz-border-top-colors:red orange yellow green cyan blue purple;
        -moz-border-right-colors: red orange yellow green cyan blue purple;
        -moz-border-bottom-colors: red orange yellow green cyan blue purple;
        -moz-border-left-colors: red orange yellow green cyan blue purple;
    }
    </style>
</head>
<body>
    <div id="div1">
    </div>
</body>
</html>

具体代码效果:

在css中实现多色边框,border-colors属性的方法

在css中实现多色边框,border-colors属性的方法

分析:在以上可以看到border-width:5px;说明使用了5中颜色,那么边框的设置我们就可以使用五种颜色。

以上是在css中实现多色边框,border-colors属性的方法的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI