I recently came across a fascinating CSS glossy button code on GitHub. The CSS contains specific fixed widths for elements such as .container
with width: 140px
, .glossy
with width: 120px
, and .glossy:before
with width: 110px
to create a glossy effect button. The current design has a fixed width, but I'm wondering if it's possible to dynamically calculate the width based on custom text input.
You can find the code snippet below:
.container {
width: 140px;
margin: 50px auto;
}
.glossy p {
margin: 6px 0 0 0;
text-align: center;
position: relative;
z-index: 1;
}
.glossy {
width: 120px;
height: 25px;
margin: 10px auto;
position: relative;
background: #94c4fe;
/* Additional CSS properties... */
}
.glossy:before {
content: "";
width: 110px;
height: 16px;
display: block;
position: absolute;
left: 5px;
/* Additional CSS properties... */
}
<div class="container">
<div class="glossy">
<p>Hello, world!</p>
</div>
</div>