How to make a transparent border using CSS?

前端 未结 4 506
攒了一身酷
攒了一身酷 2020-12-04 12:11

I\'m trying to do something like this for a client who has a blog.

\"http://i.stack.imgur.com/4h31s.png\"

4条回答
  •  星月不相逢
    2020-12-04 13:04

    Using the :before pseudo-element,
    CSS3's border-radius,
    and some transparency is quite easy:

    LIVE DEMO

    enter image description here

    CSS:

    .circle, .circle:before{
      position:absolute;
      border-radius:150px;  
    }
    .circle{  
      width:200px;
      height:200px;
      z-index:0;
      margin:11%;
      padding:40px;
      background: hsla(0, 100%, 100%, 0.6);   
    }
    .circle:before{
      content:'';
      display:block;
      z-index:-1;  
      width:200px;
      height:200px;
    
      padding:44px;
      border: 6px solid hsla(0, 100%, 100%, 0.6);
      /* 4px more padding + 6px border = 10 so... */  
      top:-10px;
      left:-10px; 
    }
    

    The :before attaches to our .circle another element which you only need to make (ok, block, absolute, etc...) transparent and play with the border opacity.

提交回复
热议问题