CSS div with double border PLUS triange at bottom - html

I'm trying to achieve this (triangle at the bottom) in CSS and I'm starting to think it's not possible.
Update: got it working - but I do hope there is a better way:
Layering 4 CSS triangles ontop of eachother using :before :after
Code: http://jsfiddle.net/dtbaker/5fhL1odg/1/
The closest I was able to get is this (using a combination of css triangles that overlap eachother).
Code so far:
http://jsfiddle.net/dtbaker/gk47ggc1/1/
<div class="blog">
<div class="blog_date">
<span class="month">Sep</span>
<span class="day">30th</span>
<span class="year">2014</span>
<div></div>
</div>
</div>
div.blog .blog_date {
z-index: 10;
top: 10px;
left: 11px;
position: absolute;
width:56px;
float:right;
text-align:center;
color:#4b443a;
background: #f8f4e9;
border-top: 2px solid #edebdf;
border-left: 2px solid #edebdf;
border-right: 2px solid #edebdf;
}
div.blog .blog_date:before {
content: '';
position: absolute;
top:-5px;
right:-5px;
left:-5px;
bottom:-5px;
border-top:1px solid #e8e6da;
border-left:1px solid #e8e6da;
border-right:1px solid #e8e6da;
}
div.blog .blog_date div{
width: 0;
height: 0;
border-style: solid;
border-width: 12px 33px 0 33px;
border-color: #e8e6da transparent transparent transparent;
position: absolute;
bottom: -16px;
z-index: 5;
left:-5px;
}
div.blog .blog_date div:before {
width: 0;
height: 0;
border-style: solid;
border-width: 10px 30px 0 30px;
border-color: #FFF transparent transparent transparent;
position: absolute;
top: -11px;
content: '';
left: -30px;
z-index: 3;
}
div.blog .blog_date div:after {
width: 0;
height: 0;
border-style: solid;
border-width: 12px 30px 0 30px;
border-color: #f8f4e9 transparent transparent transparent;
position: absolute;
top: -15px;
content: '';
left: -30px;
z-index: 4;
}
div.blog .blog_date span {
display:block;
width:100%;
}
div.blog .blog_date span.month {
font-size:13px;
height:16px;
margin-top:5px;
}
div.blog .blog_date span.day {
font-size:18px;
height:20px;
color:#c9a976;
}
div.blog .blog_date span.year {
font-size:13px;
height:16px;
}
It would be very easy via an image, but if some wiz out there can figure this out I would be very grateful.
Thanks!

I haven't tried it but maybe you can draw the line to form the border of the triangle and play with rotations? Probably won't work on every browser though.
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);

Update: got it working - but I do hope there is a better way:
Layering 4 CSS triangles ontop of eachother using :before :after
Code: http://jsfiddle.net/dtbaker/5fhL1odg/1/
div.blog .blog_date {
z-index: 10;
left: 11px;
position: absolute;
width:56px;
float:right;
text-align:center;
color:#4b443a;
background: #f8f4e9;
border-top: 2px solid #edebdf;
border-left: 2px solid #edebdf;
border-right: 2px solid #edebdf;
}
div.blog .blog_date:before {
content: '';
position: absolute;
top:-5px;
right:-5px;
left:-5px;
bottom:-2px;
border-top:1px solid #e8e6da;
border-left:1px solid #e8e6da;
border-right:1px solid #e8e6da;
}
div.blog .blog_date:after {
/* 1px outer border */
width: 0;
height: 0;
border-style: solid;
border-width: 12px 33px 0 33px;
border-color: #e8e6da transparent transparent transparent;
position: absolute;
bottom: -14px;
z-index: 2;
left:-5px;
content: '';
}
div.blog .blog_date div{
/* white separator/overlay */
width: 0;
height: 0;
border-style: solid;
border-width: 12px 33px 0 33px;
border-color: #FFF transparent transparent transparent;
position: absolute;
content: '';
z-index: 4;
bottom: -13px;
left: -5px;
}
div.blog .blog_date div:before {
/* 2px inner border */
width: 0;
height: 0;
border-style: solid;
border-width: 11px 30px 0 30px;
border-color: #edebdf transparent transparent transparent;
position: absolute;
content: '';
z-index: 3;
top: -13px;
left: -30px;
}
div.blog .blog_date div:after {
/* inner triangle */
width: 0;
height: 0;
border-style: solid;
border-width: 11px 29px 0 29px;
border-color: #f8f4e9 transparent transparent transparent;
position: absolute;
top: -14px;
content: '';
left: -29px;
z-index: 5;
}
div.blog .blog_date span {
display:block;
width:100%;
}
div.blog .blog_date span.month {
font-size:13px;
height:16px;
margin-top:5px;
}
div.blog .blog_date span.day {
font-size:18px;
height:20px;
color:#c9a976;
}
div.blog .blog_date span.year {
font-size:13px;
height:16px;
}

Try this
.blog_date{
font-family: Times New Roman; /*nearly similar to required font */
width: 100px;
}
div.blog .blog_date span.month {
float: left; /*added*/
font-size: 32px;/*changed*/
height: auto; /*changed*/
margin-top: 5px;
}
div.blog .blog_date span.day {
color: #c9a976;
float: left; /*added*/
font-size: 34px;/*changed*/
font-weight: bold;
height: auto;/*changed*/
}
div.blog .blog_date span.year {
float: left; /*added*/
font-size: 32px;/*changed*/
height: auto;/*changed*/
}
hope this help you.

Related

How to style div to make it look like my attached image [duplicate]

I am trying to create a triangle shape with the pseudo elements. like the one in the image below.
But this is what i get.
Here is what i have tried this far.
.container .form--container:before {
content: "";
position: absolute;
top: 0px;
left: 130px;
width: 28px;
height: 28px;
transform: translate(-1rem, -100%);
border-left: 1.5rem solid #979797;
border-right: 1.5rem solid #979797;
border-bottom: 1.5rem solid white;
}
The issue is with the use of border. you can check this link How do CSS triangles work? and you will understand how border works and why you get this output.
An alternative solution is to use rotation and border like this :
.box {
border: 1px solid;
margin: 50px;
height: 50px;
position:relative;
background: #f2f2f5;
}
.box:before {
content: "";
position: absolute;
width: 20px;
height: 20px;
border-top: 1px solid;
border-left: 1px solid;
top: -11px;
left: 13px;
background: #f2f2f5;
transform: rotate(45deg);
}
<div class="box">
</div>
And in case you want your box with the arrow to be transparent, here is another trick to achieve it (as the above solution consider solid color as background):
body {
margin:0;
background-image:linear-gradient(to right,yellow,pink);
}
.box {
border: 1px solid;
border-top:transparent; /*make border-top transparent*/
margin: 50px;
height: 50px;
position:relative;
/* Use gradient to mimic the border top with a transparent gap */
background:linear-gradient(to right,black 10px,transparent 10px,transparent 39px,black 39px) top/100% 1px no-repeat;
}
.box:before {
content: "";
position: absolute;
width: 20px;
height: 20px;
border-top: 1px solid ;
border-left: 1px solid;
top: -11px;
left: 14px;
transform: rotate(45deg);
}
<div class="box">
</div>
Here is another version with dashed border:
body {
margin:0;
background-image:linear-gradient(to right,yellow,pink);
}
.box {
border: 1px dashed;
border-top:transparent; /*make border-top transparent*/
margin: 50px;
height: 50px;
position:relative;
background:
repeating-linear-gradient(to right,black 0,black 3px,transparent 3px,transparent 6px) top left/10px 1px,
repeating-linear-gradient(to right,black 0,black 3px,transparent 3px,transparent 6px) top right/calc(100% - 40px) 1px;
background-repeat:no-repeat;
}
.box:before {
content: "";
position: absolute;
width: 20px;
height: 20px;
border-top: 1px dashed;
border-left: 1px dashed;
top: -11px;
left: 13px;
transform: rotate(45deg);
}
<div class="box">
</div>

Create a triangle on both top corners of Div, divided by borders

I was able to get a single triangle in the top right corner of my div by following this question and answer:
Top Right triangle in Div.
My question is how do I get another triangle in the top left as well? When I add code for the second triangle, my div comes out all messed up.
Here's what I tried.
/*TopRight (if you comment out all .TopRightTriangle you will get the TopLeft working correctly)*/
.topRightTriangle {
width: 10em;
height: 6em;
position: relative;
}
.topRightTriangle::before,
.topRightTriangle::after {
content: '';
position: absolute;
top: 0;
right: 0;
border-color: transparent;
border-style: solid;
}
.topRightTriangle::before {
border-width: 0.6em;
border-right-color: #ccc;
border-top-color: #ccc;
}
.topRightTriangle::after {
border-width: 0.5em;
border-right-color: #000;
border-top-color: #000;
}
/*TopLeft (if you comment out all .TopLeftTriangle you will get the TopRight working correctly)*/
.TopLeftTriangle {
width: 10em;
height: 6em;
position: relative;
}
.TopLeftTriangle::before,
.TopLeftTriangle::after {
content: '';
position: absolute;
top: 0;
left: 0;
border-color: transparent;
border-style: solid;
}
.TopLeftTriangle::before {
border-width: 0.6em;
border-left-color: #ccc;
border-top-color: #ccc;
}
.TopLeftTriangle::after {
border-width: 0.5em;
border-left-color: red;
border-top-color: red;
}
<div class="topRightTriangle topLeftTriangle"></div>
This is how the endDiv should look like
What about an easy way with less of code and linear-gradient:
.element {
width:300px;
height:100px;
background:
linear-gradient(to bottom left, red 50%,transparent 50%) 100% 0/50px 50px,
linear-gradient(to bottom right, green 50%,transparent 50%) 0 0/50px 50px,
linear-gradient(to bottom right, brown 50%,transparent 50%) 0 0/60px 60px,
linear-gradient(to bottom left, pink 50%,transparent 50%) 100% 0/60px 60px,
orange;
background-repeat:no-repeat;
text-align:center;
color:#fff;
font-size:40px;
}
<div class="element"> A </div>
I believe multiple before and after elements are not possible, so think you need to make an extra element overlaying. Sort of like this, but maybe it's not usable for your case? Hope it helps, sorry if it is not usable for you.
/*TopRight*/
.topRightTriangle {
width: 10em;
height: 6em;
position: relative;
}
.topRightTriangle::before,
.topRightTriangle::after {
content: '';
position: absolute;
top: 0;
right: 0;
border-color: transparent;
border-style: solid;
}
.topRightTriangle::before,
.topRightTriangle::before {
border-width: 0.6em;
border-right-color: #ccc;
border-top-color: #ccc;
}
.topRightTriangle::after,
.topRightTriangle::after {
border-width: 0.5em;
border-right-color: #000;
border-top-color: #000;
}
/*TopLeft*/
.TopLeftTriangle {
width: 10em;
height: 6em;
position: relative;
}
.TopLeftTriangle::before,
.TopLeftTriangle::after {
content: '';
position: absolute;
top: 0;
left: 0;
border-color: transparent;
border-style: solid;
}
.TopLeftTriangle::before {
border-width: 0.6em;
border-left-color: #ccc;
border-top-color: #ccc;
}
.TopLeftTriangle::after {
border-width: 0.5em;
border-left-color: red;
border-top-color: red;
}
<div class="topRightTriangle TopLeftTriangle"></div>
/*TopRight*/
.topRightTriangle {
width: 10em;
height: 6em;
position: relative;
}
.topRightTriangle::before,
.topRightTriangle::after {
content: '';
position: absolute;
top: 0;
right: 0;
border-color: transparent;
border-style: solid;
}
.topRightTriangle::before,
.topRightTriangle::before {
border-width: 0.6em;
border-right-color: #ccc;
border-top-color: #ccc;
}
.topRightTriangle::after,
.topRightTriangle::after {
border-width: 0.5em;
border-right-color: #000;
border-top-color: #000;
}
/*TopLeft*/
.TopLeftTriangle {
width: 10em;
height: 6em;
position: relative;
}
.TopLeftTriangle::before,
.TopLeftTriangle::after {
content: '';
position: absolute;
top: 0;
left: 0;
border-color: transparent;
border-style: solid;
}
.TopLeftTriangle::before {
border-width: 0.6em;
border-left-color: #ccc;
border-top-color: #ccc;
}
.TopLeftTriangle::after {
border-width: 0.5em;
border-left-color: red;
border-top-color: red;
}
<div class="topRightTriangle"><span class="TopLeftTriangle"></span></div>
Is something like this that you want?
.myDiv {
position: relative;
width: 100px;
height: 100px;
background: red;
}
.myDiv:before {
content: "";
display: block;
position: absolute;
left: 0;
top: 0;
width: 0;
height: 0;
border-top: 10px solid gray;
border-right: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid gray;
}
.myDiv:after {
content: "";
display: block;
position: absolute;
right: 0;
top: 0;
width: 0;
height: 0;
border-top: 10px solid gray;
border-right: 10px solid gray;
border-bottom: 10px solid transparent;
border-left: 10px solid transparent;
}
<div class="myDiv"></div>
Same effect slightly less CSS
HTML:
<div class="topRightTriangle"><div class="triangle-bg"></div></div>
CSS:
.topRightTriangle {
width: 10em;
height: 6em;
position: relative;
background: orange;
overflow:hidden;
}
.topRightTriangle:after, .topRightTriangle:before {
content: '\25b2';
font-size:20px;
position: absolute;
top: -12px;
border-color: transparent;
border-style: solid;
z-index:1;
}
.topRightTriangle:before {
color:red;
left: -4.5px;
transform: rotate(97deg) skewX(33deg) skewY(-8deg) scale(1.2) translate(-1px,0px)
}
.topRightTriangle:after {
color:black;
right: -3.5px;
transform: rotate(-97deg) skewX(-33deg) skewY(8deg) scale(1.2) translate(1px,0px)
}
.triangle-bg:before, .triangle-bg:after {
content: '';
position: absolute;
top: 0;
border: transparent solid;
}
.triangle-bg:before {
border-width: 0.6em;
border-left-color: #ccc;
border-top-color: #ccc;
left:0;
}
.triangle-bg:after {
right:0;
border-width: 0.6em;
border-right-color: #ccc;
border-top-color: #ccc;
}

Add CSS Arrow to Top Left of Div

I have tried to tweak the CSS from
http://jsfiddle.net/wn7JN/ to place an arrow in a <div> in the top left corner (see image below), but I can't seem to figure out how :before and :after in CSS work. Every time I update the bottom and left parameters I am left with a black arrow in the top left corner - I think the proper rotation is transform: rotate(220deg) but that is really a guess.
Edit: Is it possible to do this same CSS trick with an rgba color such as rgba(255, 123, 172, 0.25)? When I test it out the transparency becomes an issue with the border overlap.
Any help would be greatly appreciated.
.bubble {
position: relative;
width: 400px;
height: 250px;
padding: 0px;
background: #FFFFFF;
border: #000 solid 1px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
.bubble:after {
content: "";
position: absolute;
bottom: -25px;
left: 175px;
border-style: solid;
border-width: 25px 25px 0;
border-color: #FFFFFF transparent;
display: block;
width: 0;
z-index: 1;
}
.bubble:before {
content: "";
position: absolute;
top: 250px;
left: 174px;
border-style: solid;
border-width: 26px 26px 0;
border-color: #000 transparent;
display: block;
width: 0;
z-index: 0;
}
<div class="bubble"> </div>
Try like this. Added a working copy.
.bubble {
position: relative;
background:#cbe8f0;
height: 100px;
width:170px;
margin-left:30px;
border-radius:2px;
}
.bubble:after{
content:'';
position:absolute;
border:10px solid transparent;
border-top:10px solid #cbe8f0;
top:0px;
left:-10px;
}
<div class="bubble"> </div>
You can ty this solution too based on the jsfiddle.
.bubble:after
{
content: "";
position: absolute;
top:0px;
left: -21px;
border-style: solid;
border-width: 24px 0px 0px 28px;
border-color: #FFFFFF transparent;
display: block;
width: 0;
z-index: 1;
}
.bubble:before
{
content: "";
position: absolute;
top:-1px;
left:-23px;
border-style: solid;
border-width:20px 0px 0px 23px;
border-color: #000 transparent;
display: block;
width: 0;
z-index: 0;
}
http://jsfiddle.net/wn7JN/1295/
So, here's your bubble code:
.bubble {
position: relative;
width: 400px;
height: 250px;
padding: 0px;
background: #FFFFFF;
border: #000 solid 1px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
Add this line to the bottom of that: margin-left:25px; This allows there to be room to the side of your bubble for the arrow to even show up. Otherwise, it's there, but you can't see it.
for your bubble:after, change the bottom: -25px to top: 21px and change left: 175px to left: -37px, and add transform: rotate(90deg); to the bottom.
for your bubble:before, change the top: 250px to top: 20px and change left: 174px to left: -39px, and add transform: rotate(90deg); to the bottom.
You will wind up with something like this:
1
Final fiddle: http://jsfiddle.net/eq6mhbwy/

How to add a white border around a div with a right arrow?

I have a simple div on a page:
<div>Some Text</div>
Is it possible with CSS, to make something like this:
You can use this code to make a similar arrow
<div class="arrow_box">Arrow</div>
.arrow_box {
position: relative;
background: #20d568;
border: 10px solid #ffffff;
}
.arrow_box:after, .arrow_box:before {
left: 100%;
top: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.arrow_box:after {
border-color: rgba(32, 213, 104, 0);
border-left-color: #20d568;
border-width: 70px;
margin-top: -70px;
}
.arrow_box:before {
border-color: rgba(255, 255, 255, 0);
border-left-color: #ffffff;
border-width: 84px;
margin-top: -84px;
}
There is even a website to produce similar snippet like the one mentioned above.
Hope this helps!
Here is the CSS and HTML markup you need to create this effect in your own project.
<!DOCTYPE html>
<html>
<head>
<meta>
<title>title</title>
<link>
<style type="text/css">
#base {
border: 3px solid #ccc;
background: red;
display: inline-block;
height: 30px;
position: relative;
width: 50px;
padding: 10px 0px 0px 10px;
}
#base:before {
border-bottom: 22px solid transparent;
border-left: 19px solid #ccc;
border-top: 22px solid transparent;
content: "";
height: 0;
right: -22px;
position: absolute;
top: -2px;
width: 0;
}
#base:after {
border-bottom: 20px solid transparent;
border-left: 17px solid red;
border-top: 20px solid transparent;
content: "";
height: 0;
right: -17px;
position: absolute;
top: 0px;
width: 0;
}
</style>
</head>
<body>
<div id="base" >
NEXT
</div>
</body>
</html>
HTML
<div class="textBox">
Text
</div>
CSS
body{
background:#000;
}
.textBox{
padding:10px;
background-color:green;
border-top:5px solid #fff;
border-bottom:5px solid #fff;
border-left:5px solid #fff;
width:50px;
color:#fff;
position: relative;
}
.textBox::after{
content: '';
position: absolute;
width: 30px;
height: 29px;
background: green;
border-top: 5px solid #fff;
border-right: 5px solid #fff;
transform: rotate(45deg);
top: 2px;
right: -18px;
z-index: -1
}
Codepen : http://codepen.io/swapnaranjitanayak/pen/mOWrzX
Sure can using a couple of pseudo elements. Example:
<div class="arrowBox">Some Text</div>
then use the following CSS (note, I've used a red border as opposed to white so I could see it):
.arrowBox{
width: 100px;
height: 50px;
background: green;
border: 5px red solid;
display: block;
position: relative;
line-height: 50px;
color: #fff;
text-align: center;
}
.arrowBox:before{
content: '';
width: 0;
height: 0;
position: absolute;
right: -34px;
top: -5px;
border-top: 30px solid transparent;
border-bottom:30px solid transparent;
border-left: 30px solid red;
z-index: -1;
}
.arrowBox:after{
content: '';
width: 0;
height: 0;
position: absolute;
right: -25px;
top: 0;
border-top: 25px solid transparent;
border-bottom:25px solid transparent;
border-left: 25px solid green;
}
Something for you to get started:
*{
box-sizing:border-box;
}
.wrapper{
border: 1px solid #ddd;
display:inline-block;
position:relative;
}
div.arrow {
height: 50px;
line-height: 50px;
width: 75px;
background: green;
position: relative;
text-align:center;
border: 1px solid #ddd;
margin: 10px;
color:white;
font-weight:bolder;
}
div.arrow:before {
content: '';
display: block;
position: absolute;
right: 0;
top: 0;
transform: translate(100%, 0);
height: 0;
width: 0;
border-left: 25px solid green;
border-top: 25px solid transparent;
border-bottom: 25px solid transparent;
z-index:2;
}
div.arrow:after {
content: '';
display: block;
position: absolute;
right: -11px;
top: 50%;
transform: translate(100%, -50%);
height: 0;
width: 0;
border-left: 35px solid white;
border-top: 35px solid transparent;
border-bottom: 35px solid transparent;
z-index:1;
}
.wrapper:after {
content: '';
display: block;
position: absolute;
right: 0;
top: 50%;
transform: translate(100%, -50%);
height: 0;
width: 0;
border-left: 36px solid #ddd;
border-top: 36px solid transparent;
border-bottom: 36px solid transparent;
}
<div class="wrapper">
<div class="arrow">Text</div>
</div>

create a css format with socil media icon [duplicate]

I'm trying to draw a line using CSS and show text/image in the middle of the line.
.featured-images {
color: #666666;
border: 2px solid #333333;
}
<p class="featured-images">Featured</p>
This is what I want to do:
and
Wrap the text inside a span and use a :pseudo-element for the line.
Position the line(:pseudo-element) behind the span using z-index: -1, so that you could move around the text without having to worry about the line.
.featured-images {
position: relative;
color: #666666;
border: 2px solid #333333;
padding: 0 10px 0 30px;
}
.featured-images span {
color: #666666;
background: white;
padding: 0 10px;
}
.featured-images:after {
content: '';
position: absolute;
width: 100%;
height: 2px;
background: #666666;
left: 0;
top: 50%;
transform: translateY(-50%);
z-index: -1;
}
<p class="featured-images"><span>Featured</span></p>
Replicating the following:
You could use repeating-linear-gradient to do this.
body {
background: #E7EAE3;
}
.featured-images {
position: relative;
color: #666666;
padding: 0 10px 0 30px;
overflow: hidden;
}
.featured-images span {
color: #517575;
background: white;
padding: 0 10px;
}
.featured-images:after {
content: '';
position: absolute;
width: 120%;
height: 100%;
background: -webkit-repeating-linear-gradient(180deg, #463A3A 10px, #F2F2F2 10px, #F2F2F2 11px, #463A3A 11px, #463A3A 20px) repeat-x;
background: -moz-repeating-linear-gradient(180deg, #463A3A 10px, #F2F2F2 10px, #F2F2F2 11px, #463A3A 11px, #463A3A 20px) repeat-x;
background-size: 10px 31px;
margin-left: -30px;
transform: skew(-45deg);
left: 0;
z-index: -1;
}
<p class="featured-images"><span>Featured</span>
</p>
Using image instead of text.
.featured-images {
position: relative;
color: #666666;
border: 2px solid #333333;
padding: 0 10px 0 30px;
}
.featured-images span {
display: block;
width: 80px;
height: 13px;
background: url(http://lorempixel.com/80/13) no-repeat white 10px 0;
padding: 0 10px;
}
.featured-images:after {
content: '';
position: absolute;
width: 100%;
height: 2px;
background: #666666;
left: 0;
top: 50%;
transform: translateY(-50%);
z-index: -1;
}
<p class="featured-images"><span></span></p>
Something like this? JSFiddle
CSS:
.featured-images {
color: #666666;
}
p span {
margin:0;padding: 0 10px;
background: #FFFFFF;
display: inline-block;
}
p {
padding-left: 20px;
position: relative;
z-index: 2;
}
p:after {
content: "";
position: absolute;
top: 50%;
left: 0;
right: 0;
border-top: solid 1px #666666;
z-index: -1;
}
Demo 1
:root{padding: 40px}
p{
position: relative;
margin:40px auto;padding:0 10px;
background:white;
display:inline-block;
}
p:before,p:after{
content:"";
position:absolute;
z-index:-1;
right:0
}
p:before{
top:-4px;
left: -24px;
height: 24px;
width: 480px;
border:solid 1px #666666
}
p:after{
top: 50%;
width: 466px;
left: -16px;
border-top: solid 1px #666666
}
<p class="featured-images">Featured</p>
Use Pseudo element
:root{padding: 40px}
p{
position: relative;
margin:40px auto;padding:0 10px;
background:white;
display:inline-block;
}
p:before,p:after{
content:"";
position:absolute;
z-index:-1;
left:-14px;
right:0;
width: 480px
}
p:before{
top:-4px;
height: 24px;
border:solid 1px #666666
}
p:after{
top:50%;
border-top:solid 1px #666666
}
<p class="featured-images">Featured</p>
Demo 2
p{
position: relative;
margin:0;padding:0 10px;
background:white;
display:inline-block;
}
p:after{
content:"";
position:absolute;
top:50%;
left:-14px;
right:0;
width: 100vw;
border-top:solid 1px #666666;
z-index:-1;
}
<p class="featured-images">Featured</p>
Update
:root{padding: 40px}
p{
position: relative;
margin:40px auto;padding:0 10px;
background:white;
display:inline-block;
}
p:before,p:after{
content:"";
position:absolute;
z-index:-1;
right:0
}
p:before{
top:-4px;
left: -24px;
height: 24px;
width: 480px;
border:solid 1px #666666;
background-color: gray;
background-image: repeating-linear-gradient(-45deg, transparent, transparent 2px, rgba(255,255,255,.5) 2px, rgba(255,255,255,.5) 6px)
}
}
p:after{
top: 50%;
width: 466px;
left: -16px;
border-top: solid 1px #666666
}
<p class="featured-images">Featured</p>
Result http://jsfiddle.net/p8jdzqvL/embedded/result/
<div style="height: 2px; background-color: black; text-align: center">
<span style="background-color: white; position: relative; top: -0.5em;">
Stay Connected
</span>
</div>