Creating a Border Overlay for Child Divs
Problem:
You need to design a border that overlays the content of a child div, similar to the image provided.
HTML and CSS Code:
<div class="box-border box-border-participe"> <div class="box-participe"> <a>Participe</a> </div> </div>
.box-participe { background-color: #94C120; padding: 10px 40px; }
Solution:
To achieve this using pseudo elements, you can create a border and avoid extra markup. You can also control its position and size effortlessly:
body { background: grey; } .button { background: #94c120; width: 200px; height: 50px; margin: 50px; position: relative; } .button:before { content: ""; position: absolute; top: -15px; left: -15px; width: 100%; height: 100%; border: 5px solid #fff; box-sizing: border-box; }
By using this method, you can easily create a stylish border overlay for your child divs, enhancing the visual appeal of your website.
The above is the detailed content of How to Create a Border Overlay for Child Divs with Pseudo Elements?. For more information, please follow other related articles on the PHP Chinese website!