Reputation: 824
I want to create a line separator before and after a title. The line and text must have a transparent background to be able to position them on a textured background.
I am trying to take this approach: Line before and after title over image
However, my lines are on top and bottom instead of left and right:
<div class="widget widget-catalogsale-products">
<div class="page-title category-title">
<h1>Special products</h1>
</div>
</div>
.widget.widget-catalogsale-products {display: block;}
.widget-catalogsale-products {
background: url(../images/widget-catalogsale-products.gif) repeat left top;
margin-left: -500px;
padding-left: 500px;
margin-right: -500px;
padding-right: 500px;
padding-top: 106px;
padding-bottom: 50px;
margin-bottom: 46px;
}
.widget-catalogsale-products .page-title h1 {
color: #548891;
width:100%;
margin:0 auto;
overflow:hidden;
text-align:center;
line-height:1.2em;
}
.widget-catalogsale-products .page-title h1:before,
.widget-catalogsale-products .page-title h1:after {
content:'';
vertical-align:top;
display:inline-block;
width:50%;
height:0.65em;
border-bottom:7px solid #e3edef;
margin:0 2% 0 55%;
}
.widget-catalogsale-products .page-title h1:after {
margin:0 55% 0 2%;
}
.widget-catalogsale-products .price-box .price-label {display:none;}
.widget-catalogsale-products .mini-products-list .product-name {margin-left: 0;}
.widget-catalogsale-products .product-name {margin-bottom: 5px;}
.widget-catalogsale-products .block-content li.item { border: 0; padding:0 0 25px 0; }
.widget-catalogsale-products .products-grid {margin-bottom: 0;}
.widget-catalogsale-products .products-grid .product-image {padding: 5px; border: 0;}
.widget-catalogsale-products .products-grid .product-image:before {border-width: 5px; border-color: #D2B696;}
.widget-catalogsale-products .products-grid .product-name a {color: #fff;}
Can anyone find the bug in my CSS? http://jsfiddle.net/6o9m30tv/
Upvotes: 1
Views: 163
Reputation: 8402
Seems like the margin sizes you set was causing the pseudo elements to break to the next line..
here is a snippet how I got it to align and the codes i commented out
@import url(http://fonts.googleapis.com/css?family=Open+Sans:300);
body{
background-image: url(http://fr.playstation.com/media/5ZfqPjVF/BigSkyInfinity_Hero_EN.JPG);
background-repeat:no-repeat;
background-size:100% auto;
font-family: 'Open Sans', sans-serif;
}
.widget.widget-catalogsale-products {display: block;}
.widget-catalogsale-products {
background: url(../images/widget-catalogsale-products.gif) repeat left top;
margin-left: -500px;
padding-left: 500px;
margin-right: -500px;
padding-right: 500px;
padding-top: 106px;
padding-bottom: 50px;
margin-bottom: 46px;
}
.widget-catalogsale-products .page-title h1 {
color: #548891;
width:100%;
margin:0 auto;
overflow:hidden;
text-align:center;
line-height:1.2em;
}
.widget-catalogsale-products .page-title h1:before,
.widget-catalogsale-products .page-title h1:after {
content:'';
vertical-align:top;
display:inline-block;
width:20%;
height:0.65em;
border-bottom:2px solid #e3edef;
/*margin:0 2% 0 55%;*/
}
/*.widget-catalogsale-products .page-title h1:after {
margin:0 55% 0 2%;
} */
.widget-catalogsale-products .price-box .price-label {display:none;}
.widget-catalogsale-products .mini-products-list .product-name {margin-left: 0;}
.widget-catalogsale-products .product-name {margin-bottom: 5px;}
.widget-catalogsale-products .block-content li.item { border: 0; padding:0 0 25px 0; }
.widget-catalogsale-products .products-grid {margin-bottom: 0;}
.widget-catalogsale-products .products-grid .product-image {padding: 5px; border: 0;}
.widget-catalogsale-products .products-grid .product-image:before {border-width: 5px; border-color: #D2B696;}
.widget-catalogsale-products .products-grid .product-name a {color: #fff;}
<div class="widget widget-catalogsale-products">
<div class="page-title">
<h1>Special products</h1>
</div>
</div>
Upvotes: 0
Reputation: 799
You're missing comma/minus in your margin. Change it like this:
.widget-catalogsale-products .page-title h1:after {
content:'';
vertical-align:top;
display:inline-block;
width:50%;
height:0.65em;
border-bottom:7px solid #e3edef;
margin:0 2% 0 -55%;
}
.widget-catalogsale-products .page-title h1:after {
margin:0 -55% 0 2%;
}
Upvotes: 2