css · geeky

CSS3 – add arrows to boxes

To add arrows for any boxes in CSS3 is relatively easy. You may use the border, absolute position along with the :before pseudo selector to add arrows in any directions.

To make a triangle with CSS border:

border: 20px solid transparent; /* box width for your triangle */
border-right-color: #fff; /* color for your triangle, the direct is opposite of what you want. For example, if you want a left pointing arrow, then set the right border color. */

More on CSS3 shapes

To position the arrow, make sure the box container is positioned relative so the arrow may be absolutely positioned based on the box container

.box {
	position: relative;
}
.box:before {
	content: ' ';
	height: 0;
	position: absolute;
	width: 0;

	/* your arrow and the positioning css here */
}

View jsFiddle Live Demo

You can generate the arrows using this tool.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s