box-shadow do the trick:
HTML:
<section>
<span>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Doloremque dolore, temporibus consequatur.
</span>
</section>
CSS
section {
max-width:400px;
padding:50px;
margin:0 auto;
background: url('http://lorempixel.com/400/800');
background-size:cover;
height:100vh;
}
span {
font-family: sans-serif;
font-size: 2em;
font-weight: 100;
line-height: 1.8;
padding: 3px 0 6px 0;
color: rgb(255, 255, 255);
background-color: rgba(0, 0, 0, .6);
box-shadow: 10px 0 0 rgba(0, 0, 0, .6), -10px 0 0 rgba(0, 0, 0, .6);
box-decoration-break: clone;
}
UPDATE:
Now it works in Firefox. Since the default value for FF is equal box-decoration-break: split;, you must set box-decoration-break: clone;.
source
share