If you're looking for complete transparency, you can achieve that by using:
border: 5px solid transparent;
But if you want a combination of opaque and transparent border, you can use:
border: 5px solid rgba(255, 255, 255, .5);
In the rgba code, 'a' stands for alpha which determines the level of transparency on a scale from 0 to 1.
Some may recommend using the opacity
property which has a similar effect, but keep in mind that it will also affect child elements. Using rgba
provides more control compared to opacity
.
To ensure compatibility with older browsers, always include a fallback background color using hexadecimal code (#) in case the browser doesn't support rgba. This helps maintain consistency in appearance across different platforms.
Check out a demo here
Another demo with background image
One more demo using an 'img' tag instead of background-image
body {
background: url(http://www.desktopas.com/files/2013/06/Images-1920x1200.jpg);
}
div.wrap {
border: 5px solid #fff; /* Fallback option */
border: 5px solid rgba(255, 255, 255, .5);
height: 400px;
width: 400px;
margin: 50px;
border-radius: 50%;
}
div.inner {
background: #fff; /* Fallback option */
background: rgba(255, 255, 255, .5);
height: 380px;
width: 380px;
border-radius: 50%;
margin: auto; /* Horizontally centered */
margin-top: 10px; /* Vertically centered (manually calculated)*/
}
Note (For Demo 3): Make sure the image provided maintains its aspect ratio when scaled based on the height and width values given.