Bootstrap Col Width - Stack Overflow

    1. Home
    2. Questions
    3. Tags
    4. Users
    5. Companies
    6. Labs
    7. Jobs
    8. Discussions
    9. Collectives
    10. Communities for your favorite technologies. Explore all Collectives

  1. Teams

    Ask questions, find answers and collaborate at work with Stack Overflow for Teams.

    Try Teams for free Explore Teams
  2. Teams
  3. Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Get early access and see previews of new features.

Learn more about Labs Bootstrap Col width Ask Question Asked 8 years, 8 months ago Modified 8 years, 8 months ago Viewed 849 times 1

Please, first have a look on the attached imageenter image description here

I want 20% in first column, but when I used col-md-2, it set width: 16.6667% how I set column 20% using bootstrap. Do I need to make my own CSS or there is a way to customise bootstraps3

Share Improve this question Follow edited Mar 3, 2016 at 10:12 martin's user avatar martin 96.7k26 gold badges202 silver badges234 bronze badges asked Mar 3, 2016 at 9:34 Naveed Iqbal's user avatar Naveed IqbalNaveed Iqbal 1332 silver badges11 bronze badges 5
  • How many columns do you want? – Kudos Commented Mar 3, 2016 at 9:41
  • 2 Possible duplicate of How to Customize Bootstrap Column Widths? – James Donnelly Commented Mar 3, 2016 at 9:52
  • one columns is 10% and second column 20% – Naveed Iqbal Commented Mar 3, 2016 at 9:52
  • @JamesDonnelly so I need to customize in bootstrap – Naveed Iqbal Commented Mar 3, 2016 at 9:54
  • You can customize the boostrap CSS or you can just write your own CSS for what you need. – Raul A. Commented Mar 3, 2016 at 10:16
Add a comment |

2 Answers 2

Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 4

Bootstrap grid system is based in 12 columns. Here there is the Bootstrap official doc http://getbootstrap.com/css/#grid

col-md-2 means that you want to assign 2/12 of the total width of your container, therefore 16.6667%

If you'd like to assign 20% you can add a class near to col-md-2 and than override the width, or set an in-line style. Please note that if you set 20% is not a multiple of 12 so the near columns would never stretch 100% of width just using bootstrap.

Share Improve this answer Follow answered Mar 3, 2016 at 9:53 Luca's user avatar LucaLuca 15310 bronze badges Add a comment | 2

You have to use custom classes (easy way), or customize Bootstrap grid system.

For creating custom class you could use something like:

.col-10p { width: 100%; } .col-20p { width: 100%; } @media screen and (min-width: 768px) { .col-10p { width: 10%; float: left; } .col-20p { width: 20%; float: left; } }

Then you will get 10% and 20% width containers respectively, and will be responsive like col-md-*s. These can be used just like col-*-* classes.

If you customize Bootstrap or overwrite default grid classes it'll effect the whole project and will make unintended results.

Like this you can overwrite classes:

.col-md-2 { width: 10% !important; }

Since using !important is not a good way to do things: you could use another approach like:

.width-10.col-md-2 { width: 10%; }

which will give you desired effect. Just use the width-10 class in HTML too.

Share Improve this answer Follow edited Mar 3, 2016 at 10:16 answered Mar 3, 2016 at 10:09 Asim K T's user avatar Asim K TAsim K T 18k13 gold badges81 silver badges106 bronze badges Add a comment |

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid …

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Draft saved Draft discarded

Sign up or log in

Sign up using Google Sign up using Email and Password Submit

Post as a guest

Name Email

Required, but never shown

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.

  • The Overflow Blog
  • We'll Be In Touch - A New Podcast From Stack Overflow!
  • The app that fights for your data privacy rights
  • Featured on Meta
  • More network sites to see advertising test
  • We’re (finally!) going to the cloud!
  • Call for testers for an early access release of a Stack Overflow extension...
Visit chat

Linked

52 How to Customize Bootstrap Column Widths? 2550 How do I reduce the opacity of an element's background using CSS? 2810 Make a div fill the height of the remaining screen space 1236 Center a column using Twitter Bootstrap 1957 Hide scroll bar, but while still being able to scroll 1463 Maintain the aspect ratio of a div with CSS 1825 Font scaling based on size of container 1650 How do I style a <select> dropdown with only CSS? 1129 How can I use a not:first-child selector? 1119 Make body have 100% of the browser height 667 Expand a div to fill the remaining width

Hot Network Questions

  • A dark animated movie about an orphaned girl working in an oppressive factory
  • Where in the Gospels does Jesus explain what 'The Truth' is?
  • NginX Permission denied
  • Am I correct in assuming during the merger with the Milky Way the structure of the Andromeda Galaxy will not be visible to the naked eye?
  • Is the following necessarily true?
  • Strange Brackets in String Writing
  • How to generate short 60V pulses from 3V source?
  • Transformations on correlation functions
  • Boy who can see EM waves but loses the ability because of a thunderstorm
  • Do rediscoveries justify publication?
  • Missile Impact Velocity
  • Can a storage device completely erase itself while performing the erase?
  • Superimposed triangles
  • Are Quantum Algorithms better than classical algorithms for all problems?
  • Top loading an Aircraft vs bottom Loading
  • Is there a theorem in metaphysics that basically says, "Biting the bullet will be inevitable in any metaphysical theory?"
  • Non buddhist gods
  • Brushing pastries with jam
  • Did Superdana manufacture a 66 AC outlet power strip/surge protector?
  • Are "Albergue de peregrinos" typically restricted to pilgrims?
  • How can I solve a multi-delay differential equation?
  • How to stop Apple Sports live activities watch notifications?
  • Why would you not issue orders to a facility?
  • Quantitative definition of information without set cardinality or probability?
more hot questions Question feed Subscribe to RSS Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

lang-html

Từ khóa » Html Bootstrap Col Size