Question

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.

Was it helpful?

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

OTHER TIPS

You could use the :after pseudo-element with the same styles plus display: block; content: ""; background-color: white (or whatever the BG is actually supposed to be).

http://jsfiddle.net/ExplosionPIlls/hbzHZ/15/

Here you have http://jsfiddle.net/bqX3S/28/ The point is to use the same width and top value

width: 100px;
top: 100px;

So if change #arrow width you need to change top in for :after and :before elements as well

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top