box-shadow会有一个类似border出现

"Hello World, Hello Blog"

Posted by wudimingwo on December 15, 2018

出现边框.png

▪html

1
         <div></div>

▪css

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
div{
              width: 100px;
              height: 100px;
              
              margin: 200px auto;
              
              border-radius: 50%;
              border: 1px solid #CCCCCC;
              background-image: linear-gradient(to bottom,white 50%,black 50%,black);
              
              position: relative;
            }
            
            div:before,div:after{
              content: '';
              display: block;
              width: 50px;
              height: 50px;
              border-radius: 50%;
              position: absolute;
              top: 50%;
              transform: translateY(-50%);
              box-sizing: border-box;
            }
            div:before {
              left: 0;
              background-color: black;
              box-shadow: 0px 0px 0px 18px #fff inset;
            }
            div:after {
              right: 0;
              border: 1px solid black;
              background-color: white;
              box-shadow: 0px 0px 0px 18px #000 inset ;
            }