Search code examples
cssarrows

(Down) Arrow Box with CSS


I want to do what this arrow box does, but instead of an arrow pointing to the right, I want it to point downward.

I've tried something like this: jsfiddle link here

#triangle-down {
    width: 0;
    height: 0;
    border-left: 150px solid transparent;
    border-right: 150px solid transparent;
    border-top: 30px solid red;
}
#body {
    background-color: red;
    width:300px;
}

<div id="body">
     <h2>Title</h2>

    <p>this is text.</p>
</div>
<div id="triangle-down"></div>

It tends to be unreliable in terms of lining up the two divs. I'd like a one div solution.


Solution

  • Here you are... added some base styles for multiple posible directions as well... http://jsfiddle.net/hbzHZ/16/

    Uses two alternatives, one with inner div, another with pseudo-element :after