Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a circular button in BS3

I want to create a rounded button in BS3 (a perfect circle), with a single fontawesome(4.0) icon in the center.

So far, I have the following code:

HTML:

<a href="#" class="btn btn-default"><i class="fa fa-user"></i></a> 

What would the CSS markup be to make this button a perfect circle?

like image 581
alias51 Avatar asked Oct 26 '13 00:10

alias51


2 Answers

you can do something like adding a class to add border radius

HTML:

<a href="#" class="btn btn-default btn-circle"><i class="fa fa-user"></i></a> 

CSS:

.btn-circle {   width: 30px;   height: 30px;   text-align: center;   padding: 6px 0;   font-size: 12px;   line-height: 1.42;   border-radius: 15px; } 

in case you wanted to change dimension you need to change the font size or padding accordingly

like image 86
Tarik Avatar answered Sep 18 '22 09:09

Tarik


(Not cross-browser tested), but this is my answer:

.btn-circle {   width: 40px;   height: 40px;   line-height: 40px; /* adjust line height to align vertically*/   padding:0;   border-radius: 50%; } 
  • vertical center via the line-height property
  • padding becomes useless and must be reset
  • border-radius independant of the button size
like image 37
chocopoche Avatar answered Sep 21 '22 09:09

chocopoche