Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is the caret on Twitter Bootstrap constructed?

This is more of a curiosity question than something I really need to know.

On this page:

http://twitter.github.com/bootstrap/components.html#buttonDropdowns

How is the little caret / down arrow thing constructed? Poking around with Firebug it looks like it's just made with transparent borders but ... I must be missing something.

Bootstrap is very cool. I just got it going with Symfony.

like image 252
tetranz Avatar asked Jan 18 '13 18:01

tetranz


People also ask

Is twitter built with Bootstrap?

Twitter Bootstrap was originally named as Twitter Blueprint before it was released as an open-source project on GitHub on August 19th, 2011. Bootstrap was created as an internal tool with the aim of eliminating inconsistencies among developers using different tools.

What does Twitter, Bootstrap have to do with Web sites?

Twitter Bootstrap is a front end framework to develop web apps and sites fast. In modern web development, there are several components which are required in almost all web projects. Bootstrap provides you with all those basic modules - Grid, Typography, Tables, Forms, Buttons, and Responsiveness.


1 Answers

It is only with borders. When you see arrows like this, the developer most likely used pseudo elements to create them. Basically what happens is you create a transparent box without content, and since there is nothing there, all you see is the one corner of the border. This conveniently looks just like an arrow.

How to do it:

.foo:before {
    content: ' ';
      height: 0;
      position: absolute;
      width: 0;
      border: 10px solid transparent;
      border-left-color: #333;
}

http://jsfiddle.net/fGSZx/

Here are some resources to help:

CSS Triangle from CSS-Tricks (this should clear everything up)

Smashing Mag article about :before and :after

like image 79
Jason Avatar answered Sep 20 '22 07:09

Jason