I'm trying to achieve a title (h1) at the top of a template like the following (the dots represent a vertically centered dot-image-line):
title example http://www.pixelplus.nl/klanten/klijsen/example.jpg
Usually I'd do this:
<h1><span>This is a title</span></h1>
Center the text in the h1
and add a background-color to the span
as well as a little padding.
In the current project I'm dealing with a transparent background over a background-image
. So... the background-colored span
won't fly.
After trying a few things this comes closest:
<header class="headerPage">
<div class="row">
<div class="dotted"> </div>
<div class="title"><h1>This is a title</h1></div>
<div class="dotted"> </div>
</div>
</header>
And this CSS:
header.headerPage {
display: table;
margin: 0 0 35px;
width: 100%;
}
header.headerPage .row {display: table-row;}
header.headerPage .row div {display: table-cell;}
header.headerPage .row div.dotted {
width: 10%;
background: url('../img/line-dotted.svg') left center repeat-x transparent;
}
header.headerPage .row div.title {
padding: 0 15px;
text-align: center;
}
header.headerPage .row div.title > * {display: inline;}
header.headerPage .row div h1 {margin: 0;}
As you can see the header acts as a table
. The problem is in the width: 10%;
of the dotted-divs. How do I get these to have a variable width relative to the dynamic height of the h1
? Hope this can be done in css / scss.