Reputation: 35
I am trying to make a css headline that looks like this
I have the triangle as a png with transparency, but I haven't really used pseudo elements before, so if anyone could help that would be awesome.
So far I've got this:
h1 {text-transform: uppercase;font-weight: 600; margin: 0; padding: 0;}
h1:before {
content: url( "../images/triangle.png" ) ;
margin-right: -50px;}
This places the text correctly horizontally, but I can't find a way to place the text correctly vertically
Upvotes: 1
Views: 56
Reputation: 6490
Please check the fiddle - http://jsfiddle.net/afelixj/obmwncd4/
To add background image, remove all the border in h1:before
, and add width and height of the image
Upvotes: 1
Reputation: 7217
you can try like this: Demo
h1 {
text-transform: uppercase;
font-weight: 600;
margin: 0;
padding: 0;
position:relative;
z-index:9999;
line-height:80px;
text-indent:20px;
}
h1:before {
width: 0;
height: 0;
margin: 0;
padding: 0;
border-top: 100px solid red;
border-right: 100px solid transparent;
content:"";
display:block;
position:absolute;
z-index: -1;
/* to be below the parent element */
}
HTML:
<h1>fddfgfdg</h1>
Upvotes: 0
Reputation: 55
so you want to make the text vertical ? try this
.vertical-text {
transform: rotate(90deg);
transform-origin: left top 0;
float: left;
}
Upvotes: 0
Reputation: 9652
You can use below css and manage this via position:
h1 {
text-transform: uppercase;
font-weight: 600;
margin: 0;
padding: 0;
position: relative
}
h1:before {
content: "";
position:absolute;
width: 40px;
height: 40px;
background: url( "../images/triangle.png" );
right: -50px;
top: 0px;
}
Upvotes: 2