html5 - css3 上锯齿边框只有半个

查看:133
本文介绍了html5 - css3 上锯齿边框只有半个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        .bg1 {
            /* width: 300px; */
            height: 50px;
            /* background: #caca8c; */
            background-image: -webkit-gradient(linear, 50% 0, 0 100%, from(transparent), color-stop(.5, transparent), color-stop(.5, #f5f5f5), to(#f5f5f5)), -webkit-gradient(linear, 50% 0, 100% 100%, from(transparent), color-stop(.5, transparent), color-stop(.5, #f5f5f5), to(#f5f5f5));
            background-size: 7px 5px;
            background-repeat: repeat-x;
            background-position: 0 100%;
        }
        
        .bg2 {
            height: 50px;
            /* background: #caca8c; */
            background-image: -webkit-gradient(linear, 50% 0, 0 100%, from(#f5f5f5), color-stop(.5, #f5f5f5), color-stop(.5, transparent), to(transparent)), -webkit-gradient(linear, 50% 0, 0 100%, from(#f5f5f5), color-stop(.5, #f5f5f5), color-stop(.5, transparent), to(transparent));
            background-size: 7px 5px;
            background-repeat: repeat-x;
            background-position: 0 0;
        }
        
        .gray {
            height: 24px;
            background: #f5f5f5;
        }
    </style>
</head>

<body>
    <div class="bg1"></div>
    <div class="gray"></div>
    <div class="bg2"></div>
</body>

</html>

bg2的上的锯齿如何变得完整,它只有半个,如何像bg1那样完整,但是他是在上边,bg1是在下边,麻烦大家帮我看一下是哪里出错了,谢谢

解决方案

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        .bg1 {
            /* width: 300px; */
            height: 50px;
            /* background: #caca8c; */
            background-image: -webkit-gradient(linear, 50% 0, 0 100%, from(transparent), color-stop(.5, transparent), color-stop(.5, #f5f5f5), to(#f5f5f5)), -webkit-gradient(linear, 50% 0, 100% 100%, from(transparent), color-stop(.5, transparent), color-stop(.5, #f5f5f5), to(#f5f5f5));
            background-size: 7px 5px;
            background-repeat: repeat-x;
            background-position: 0 100%;
        }
        
        .bg2 {
               background-repeat: repeat-x;
            background-position: 0 100%;
               background-size: 7px 7px;
               height: 24px;
            background-image: -webkit-linear-gradient(45deg ,#fff 25% ,transparent 25%),
                              -webkit-linear-gradient(-45deg ,#fff 25% ,transparent 25%);
              background-image: linear-gradient(45deg ,#fff 25% ,transparent 25%),
            linear-gradient(-45deg ,#fff 25% ,transparent 25%);
            
        }
        
        .gray {
            height: 24px;
            background: #f5f5f5;
        }
    </style>
</head>

<body>
    <div class="bg1"></div>
    <div class="gray">
            <div class="bg2"></div>
    </div>
    
</body>

这篇关于html5 - css3 上锯齿边框只有半个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆