How to make a transparent border using CSS?

前端 未结 4 511
攒了一身酷
攒了一身酷 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 12:50

    You can also use border-style: double with background-clip: padding-box, without the use of any extra (pseudo-)elements. It's probably the most compact solution, but not as flexible as the others.

    For example:

    Some text goes here...
    .circle{ width: 100px; height: 100px; padding: 50px; border-radius: 200px; border: double 15px rgba(255,255,255,0.7); background: rgba(255,255,255,0.7); background-clip: padding-box; }

    Result

    If you look closely you can see that the edge between the border and the background is not perfect. This seems to be an issue in current browsers. But it's not that noticeable when the border is small.

提交回复
热议问题