简体   繁体   中英

How to make bootstrap button responsive?

I have bootstrap button having width of 128px and height of 30px .

When I resize my browser window, the buttons are not responsive.

What am I missing?

 .common_btn{ width: 128px; height: 30px; float: right; margin: 0 15px; } 
 <button class="btn mb-xs w-xs btn-danger common_btn " style="float:left;">New Contact</button> <button class="btn mb-xs w-xs btn-danger common_btn " >Delete</button> <button class="btn mb-xs w-xs btn-dark common_btn" >Save</button> 

For this you can specify the width of the buttons by using media queries.

/ For tablet and below device/ @media (max-width: 768px) { ... }

Use a percentage(%) instead of set pixels.

Example:

width: 20%;

change fixed width size in to %

.common_btn{
   width: calc( 100% - 30px) /* take total container width and reduce 30px */
   height: 30px; 
   float: right; 
   margin: 0 15px;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM