Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resizing buttons in Twitter-Bootstrap

I'm developing a mobile-friendly web app which I would like to feature a dead-simple UI, including buttons so large even Andre the Giant could tap them with ease.

The problem is, I see no simple way of explicitly resizing bootstrap buttons by setting their width or height to a percentage, number of pixels, or simply having them fill their containers. Is there a canonical way of greatly enlarging buttons outside of using 'btn btn-small' or 'btn btn-large' classes, or is this considered a bad practice?

like image 541
Chazu Avatar asked Oct 28 '12 19:10

Chazu


People also ask

How do I change the button size in Bootstrap?

Sizes. Fancy larger or smaller buttons? Add .btn-lg or .btn-sm for additional sizes. Create block level buttons—those that span the full width of a parent—by adding .btn-block .

How do I make Bootstrap button smaller?

Use the . btn-sm class in Bootstrap to create a small button.

Can you customize Bootstrap buttons?

Because of its framework, Bootstrap's buttons are already styled when they're added to the site. However, if you want to create your own custom button style, you can do that in Bootstrap's CSS file. If you haven't yet installed Bootstrap on your server, see our Setting Up Bootstrap on Your Server article.

How do I move a button to the right in Bootstrap?

Answer: Use the text-right Class You can simply use the class . text-right on the containing element to right align your Bootstrap buttons within a block box or grid column. It will work in both Bootstrap 3 and 4 versions.


1 Answers

Bootstrap is a great framework, but it doesn't cover everything. It knows that and using its OOCSS principle should be extended to your needs.

If I'm adapting Bootstrap components themselves, I generally create a bootstrap-extensions.css file which houses any extensions of base components, such as an extra large button.

Here's an example implementation of how one extension class adds a new family of buttons to the framework. This example also includes an example use of .btn-block, which is already included in the framework.

CSS:

/**  * Extra large button extensions. Extends `.btn`.  */ .btn-xlarge {     padding: 18px 28px;     font-size: 22px;     line-height: normal;     -webkit-border-radius: 8px;        -moz-border-radius: 8px;             border-radius: 8px;     } 

Demo: http://jsfiddle.net/Pspb9/

like image 88
amustill Avatar answered Sep 22 '22 09:09

amustill