Here's a possible solution:
See Demo
To achieve this effect, simply use a container div
with an rgba
background.
HTML:
<div id="boxOuter">
<div id="box">THANK YOU!</div>
</div>
CSS:
#box{
background-color:#ccc;font-weight:bold;
text-align:center;
line-height:100px;
height:100px;
vertical-align:middle;
font-size:20px;
}
#boxOuter {
background: rgba(0,0,0,0.5); width:300px; padding: 10px;
margin-left:25px;
}
Refer to the comments for tips on making this method (rgba
) compatible with older browsers.
An alternative approach without using a wrapper:
Try using outline
instead of border
. It provides a similar result:
outline: 10px solid rgba(0,0,0,0.5)
Live Demo (just one word changed in your original code)
(Consideration excludes IE in this scenario)
You may find this article helpful:
http://css-tricks.com/transparent-borders-with-background-clip/