Translucent border Result: Implementation code: <div> Can you see the semi-transparent border? </div> div { /* Key code */ border: 10px solid rgba(255,255,255,.5); background: white; background-clip: padding-box; /* Other styles */ max-width: 20em; padding: 2em; margin: 2em auto 0; font: 100%/1.5 sans-serif; } Implementation points: Set the border to semi-transparent. You cannot see the semi-transparent border because, by default, the background extends to the lower layer of the area where the border is located, that is, the background is cut off by the outer edge of the border. By setting background-clip: padding-box (the initial value is border-box), the background is prevented from extending below the border area, that is, the outer edge of the padding is used to clip the background. Multiple borders Result: Implementation code: <div></div> /* box-shadow implementation */ div { /* Key code */ box-shadow: 0 0 0 10px #655, 0 0 0 15px deeppink, 0 2px 5px 15px rgba(0,0,0,.6); /* Other styles */ width: 100px; height: 60px; margin: 25px; background: yellowgreen; } /* border/outline implementation */ div { /* Key code */ border: 10px solid #655; outline: 5px solid deeppink; /* Other styles */ width: 100px; height: 60px; margin: 25px; background: yellowgreen; } Implementation points: The box-shadow implementation uses the fourth parameter of box-shadow (expansion radius). A positive dilation radius plus two zero offsets and zero blur values results in a "projection" that actually looks like a solid border. With the help of box-shadow supporting comma-separated syntax, any number of shadows can be created, so we can achieve multiple border effects. The border/outline implementation is to use border to set a border layer, and then use outline to set a border layer. This solution can achieve a dotted border, but it can only achieve two layers of borders. Border inner corners Result: Implementation code: <div>I have a nice rounded corner</div> div { outline: .6em solid #655; box-shadow: 0 0 0 .4em #655; /* Key code*/ max-width: 10em; border-radius: .8em; padding: 1em; margin: 1em; background: tan; font: 100%/1.5 sans-serif; } Implementation points: The outline doesn’t follow the rounded corners of the element (thus appearing as a right angle), but the box-shadow does, so by adding the two together, the box-shadow (whose expansion value is roughly equal to half the value of border-radius) will just fill the gap between the outline and the container’s rounded corners, thus achieving the effect we want. Summarize The above is what I introduced to you about how to achieve various border effects with CSS3. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! |
<<: How to install docker using YUM
>>: MySQL cursor functions and usage
Table of contents Creating an SSL Certificate 1. ...
There are two ways: 1. Service method Check the f...
Based on Vue The core idea of this function is ...
1. Replace your .js library file address with the...
Problem description (what is keep-alive) keep-ali...
Floating elements cause their parent elements to ...
1. Unzip mysql-8.0.21-winx64 2. Configure environ...
Table of contents 1. Database Overview 1.1 Develo...
123WORDPRESS.COM--HTML超文本标记语言速查手册<!-- --> !D...
1. Write a backup script rem auther:www.yumi-info...
Table of contents 1. Introducing Typescript 2. Co...
Hello everyone, today I will share with you the i...
This article shares the MySQL Workbench installat...
Table of contents Preface 1. Arrange the installa...
Get the number of connections --- Get the maximum...