Inline Text with background-color
by djesse
HTML
<h1><span class="lines"><span class="content"><span class="wrap">This is a fancy multicolum heading width a bock-style backgound for comlete text rows and a inline-style ending.</span></span></span></h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus.</p>
CSS
/* Das Eternelement bekommt die gewünschte Hintergrund, ausgenommen der untersten Textzeile */
body {
background: #fff;
}
h1 {
position:relative;
overflow:hidden;
display:block;
color: #fff;
background-image: linear-gradient(bottom, rgba(0,0,0,0) 25px, rgb(100,100,100) 0%);
background-image: -o-linear-gradient(bottom, rgba(0,0,0,0) 25px, rgb(100,100,100) 0%);
background-image: -moz-linear-gradient(bottom, rgba(0,0,0,0) 25px, rgb(100,100,100) 0%);
background-image: -webkit-linear-gradient(bottom, rgba(0,0,0,0) 25px, rgb(100,100,100) 0%);
background-image: -ms-linear-gradient(bottom, rgba(0,0,0,0) 25px, rgb(100,100,100) 0%);
}
/* Trennlinien für mehrzeilige Überschriften */
.lines {
display:block;
font-family: Arial;
font-size: 14px;
font-weight: bold;
background-size: auto 25px;
margin-bottom: -2px;
padding-right: 20px;
background-image: linear-gradient(bottom, rgb(255,255,255) 1px, rgba(0,0,0,0) 0%);
background-image: -o-linear-gradient(bottom, rgb(255,255,255) 1px, rgba(0,0,0,0) 0%);
background-image: -moz-linear-gradient(bottom, rgb(255,255,255) 1px, rgba(0,0,0,0) 0%);
background-image: -webkit-linear-gradient(bottom, rgb(255,255,255) 1px, rgba(0,0,0,0) 0%);
background-image: -ms-linear-gradient(bottom, rgb(255,255,255) 1px, rgba(0,0,0,0) 0%);
}
/* Inline-Hintergrund des Textes. Wird nur in der letzten Zeile mehrzeiliger Überschriften sichtbar */
h1 .content {
position:relative;
top: -1px;
width: 90%;
background: rgb(100,100,100);
line-height: 25px;
padding: 3px 20px 3px 0px;
background-size: auto 400px;
background-position: bottom center;
}
h1 .wrap {
position:relative;
left: 10px;
}
/* Block-Hintergrund für einzeilige Headings absichern */
.lines:before {
display:block;
content:"";
position: absolute;
width: 100%;
height: 24px;
background: rgb(100,100,100);
}