I'm not an expert with CSS and I'm gonna be struggled in order to achieve the following shape for my div:
And then I would like to insert text in the center.
How can I obtain this shape ?
Below here, some my attempts:
<div class="triangle-down-white" style="height:400px;">
try
</div>
and css
.triangle-down-white {
width: 100%;
height: 0;
padding-left:50%;
padding-top: 4%;
overflow: hidden;
background: rgba(140, 140, 140, 0.33);
}
.triangle-down-white:before,
.triangle-down-white:after {
content: "";
display: block;
height: 122px;
width: 122px;
margin-left:-1000px;
border-left: 1000px solid transparent;
border-right: 1000px solid transparent;
border-top: 100px solid rgba(140, 140, 140, 0.33);
}
.triangle-down-white:before
{ /* hide arrow tails background */
border-top: 100px solid white;
}
UPDATE I added the new style chevron but the text appear behind the div. I'm using bootstrap and the html code is the following:
<div class="row">
<div class="col-sm-12" id="chevron">
<p>asdasdasdasasdaasdsadasadsadsasd</p>
</div>
</div>
The rest of the code is completely the standard one for bootstrap.
SOLVED
I added z-index: -1 at the new element.
Taken from this website here is the chevron shape you desire:
#chevron {
position: relative;
text-align: center;
padding: 12px;
margin-bottom: 6px;
height: 60px;
width: 200px;
}
#chevron:before {
content: '';
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 51%;
background: red;
-webkit-transform: skew(0deg, 6deg);
-moz-transform: skew(0deg, 6deg);
-ms-transform: skew(0deg, 6deg);
-o-transform: skew(0deg, 6deg);
transform: skew(0deg, 6deg);
}
#chevron:after {
content: '';
position: absolute;
top: 0;
right: 0;
height: 100%;
width: 50%;
background: red;
-webkit-transform: skew(0deg, -6deg);
-moz-transform: skew(0deg, -6deg);
-ms-transform: skew(0deg, -6deg);
-o-transform: skew(0deg, -6deg);
transform: skew(0deg, -6deg);
}
p{
position: relative;
z-index: 1;
}
<div id="chevron"><p>Hello</p></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With