4

I'm trying to use CSS3 to make this custom shape using css3.

shape
(source: mattieumoreau.com)

I would like to add text over it, and the red color is the background of my website (it will be a background image, so it has to be transparent.

thanks a lot for your help

0

2 Answers 2

2

You can use

h1.elaborate{
    height:50px;
    line-height:50px;
    margin:0 50px;/*50 being the width of the arrows x2*/
    padding:0 25px;
    background:black;
    color:white;
    position:relative;
    box-sizing:border-box;
}
h1.elaborate:before,
h1.elaborate:after{
    content:'';
    position:absolute;
    width:0;
    height:0;
    border:25px solid black;
    border-left-color:transparent;
    border-right-color:transparent;
}
h1.elaborate:before{left:-25px;}
h1.elaborate:after{right:-25px;}

and use it as

<h1 class="elaborate">I am the elaborate title</h1>

Demo at http://dabblet.com/gist/9209450

(and hover over the title at http://dabblet.com/gist/9209563 to see a sort of explanation of how it works)

Sign up to request clarification or add additional context in comments.

Comments

0

Here you go:

HTML:

<div class="container">
    <div class="tl"></div>
    <div class="tr"></div>
    <div class="br"></div>
    <div class="bl"></div>
</div>

CSS:

.container {
    width: 60%;
    height: 100px;
    margin: 0 auto;
    position: relative;
    background-color: #000;
}

.tl {
    top: 0;
    left: -25px;
    position: absolute;
    border-top: 25px solid #000;
    border-left: 25px solid transparent;
    border-right: 25px solid #000;
    border-bottom: 25px solid transparent;
}
.tr {
    top: 0;
    right: -25px;
    position: absolute;
    border-top: 25px solid #000;
    border-left: 25px solid #000;
    border-right: 25px solid transparent;
    border-bottom: 25px solid transparent;
}
.br {
    bottom: 0;
    right: -25px;
    position: absolute;
    border-top: 25px solid transparent;
    border-left: 25px solid #000;
    border-right: 25px solid transparent;
    border-bottom: 25px solid #000;     
}
.bl {
    bottom: 0;
    left: -25px;
    position: absolute;
    border-top: 25px solid transparent;
    border-left: 25px solid transparent;
    border-right: 25px solid #000;
    border-bottom: 25px solid #000;
}

Here's a demo: FIDDLE

Example 2 with text and red background

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.