I want to adjust the columns in Twitter Boοtstrap.
I know in bootstrap there are 12 columns grid. Is there any way to manipulate the grids to have 1.5 3.5 3.5 3.5 instead of 3 3 3 3?
I want to adjust the columns in Twitter Boοtstrap.
I know in bootstrap there are 12 columns grid. Is there any way to manipulate the grids to have 1.5 3.5 3.5 3.5 instead of 3 3 3 3?
12
Answers
The short answer is no (technically you can give whatever name of the class you want, but this will have no effect, unless you define your own CSS class – and remember – no dots in the class selector). The long answer is again no, because Bootstrap includes a responsive, mobile first fluid grid system that appropriately scales up to 12 columns as the device or view port size increases.
Rows must be placed within a
.container
(fixed-width) or.container-fluid
(full-width) for proper alignment and padding..row
and.col-xs-4
are available for quickly making grid layouts. Less mixins can also be used for more semantic layouts..rows
..col-xs-4
..col-md-*
class to an element will not only affect its styling on medium devices but also on large devices if a.col-lg-*
class is not present.A possible solution to your problem is to define your own CSS class with desired width, let’s say
.col-half{width:XXXem !important}
then add this class to elements you want along with original Bootstrap CSS classes.This is not Bootstrap Standard to give col-md-1.5 and you can not edit bootstrap.min.css because is not right way.
you can create like this http://www.bootply.com/125259
As @bodi0 correctly said, it is not possible. You either have to extent Bootstrap’s grid system (you can search and find various solutions, here is a 7-column example) or use nested rows e.g. http://bootply.com/dd50he9tGe.
In the case of nested rows you might not always get the exact result but a similar one
You cloud also simply override the width of the Column…
Since
col-md-1
is of width 8.33333333%; simply multiply 8.33333333 * 1.5 and set it as your width.in
bootstrap 4
, you will have to override flex and max-width property too:Create new classes to overwrite the width. See jFiddle for working code.
As others mentioned in Bootstrap 3, you can use nest/embed techniques.
However it is becoming more obvious to use pretty awesome feature from Bootstrap 4 now. you simple have the option to use the
col-{breakpoint}-auto
classes (e.g.col-md-auto
) to make columns size itself automatically based on the natural width of its content. check this for exampleThis question is quite old, but I have made it that way (in TYPO3).
Firstly, I have made a own accessible css-class which I can choose on every content element manually.
Then, I have made a outer three column element with 11 columns (1 – 9 – 1), finally, I have modified the column width of the first and third column with CSS to 12.499999995%.
Bootstrap 4 uses flex-box and you can create your own column definitions
This is close to a 1.5, tweak to your own needs.
you can use this code inside col-md-3 , col-md-9
According to Rex Bloom response I have write a bootstrap helper:
Bootstrap has column offsets, so if you want columns with equal width without specifying size use this.
Also check out this link
https://getbootstrap.com/docs/4.0/layout/grid/#all-breakpoints
I have created a custom bootstrap extension that allows you to use the following classes:
Also note that you can use responsive classes, such as:
col-sm-2-half
(2.5)col-md-0-3qtr
(0.75)col-lg-11-1qtr
(11.25)col-xl-5-half
(5.5)Here is an example: