Bootstrap 4 add more sizes spacing
up vote
1
down vote
favorite
I'm in the middle of a web project, where spaces between sections have 80px.
I would like to create one more option in the bootstrap spacers.
For the moment I have in the sass code:
section {
padding: 0 80px;
}
Bootstrap spacers range from .25em to 3em (.p-5 = 40px)
I would like to create a .p-6
class containing 5em (80px)
The ideal would be:
<section class="py-5 py-md-6">
A bootstrap I have linked via CDN. I can not imagine how to create this with variables, somehow integrating it into the boostrap css. Could you give me any clues?
css twitter-bootstrap sass spacing
add a comment |
up vote
1
down vote
favorite
I'm in the middle of a web project, where spaces between sections have 80px.
I would like to create one more option in the bootstrap spacers.
For the moment I have in the sass code:
section {
padding: 0 80px;
}
Bootstrap spacers range from .25em to 3em (.p-5 = 40px)
I would like to create a .p-6
class containing 5em (80px)
The ideal would be:
<section class="py-5 py-md-6">
A bootstrap I have linked via CDN. I can not imagine how to create this with variables, somehow integrating it into the boostrap css. Could you give me any clues?
css twitter-bootstrap sass spacing
mixing bootstrap margin and padding would give the 80px i guess (p-5 m-5
). would this be compatible with other styled applied(bg, border, ...)?
– G-Cyr
Sep 8 '17 at 15:09
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm in the middle of a web project, where spaces between sections have 80px.
I would like to create one more option in the bootstrap spacers.
For the moment I have in the sass code:
section {
padding: 0 80px;
}
Bootstrap spacers range from .25em to 3em (.p-5 = 40px)
I would like to create a .p-6
class containing 5em (80px)
The ideal would be:
<section class="py-5 py-md-6">
A bootstrap I have linked via CDN. I can not imagine how to create this with variables, somehow integrating it into the boostrap css. Could you give me any clues?
css twitter-bootstrap sass spacing
I'm in the middle of a web project, where spaces between sections have 80px.
I would like to create one more option in the bootstrap spacers.
For the moment I have in the sass code:
section {
padding: 0 80px;
}
Bootstrap spacers range from .25em to 3em (.p-5 = 40px)
I would like to create a .p-6
class containing 5em (80px)
The ideal would be:
<section class="py-5 py-md-6">
A bootstrap I have linked via CDN. I can not imagine how to create this with variables, somehow integrating it into the boostrap css. Could you give me any clues?
css twitter-bootstrap sass spacing
css twitter-bootstrap sass spacing
asked Sep 8 '17 at 14:59
nicogaldo
185218
185218
mixing bootstrap margin and padding would give the 80px i guess (p-5 m-5
). would this be compatible with other styled applied(bg, border, ...)?
– G-Cyr
Sep 8 '17 at 15:09
add a comment |
mixing bootstrap margin and padding would give the 80px i guess (p-5 m-5
). would this be compatible with other styled applied(bg, border, ...)?
– G-Cyr
Sep 8 '17 at 15:09
mixing bootstrap margin and padding would give the 80px i guess (
p-5 m-5
). would this be compatible with other styled applied(bg, border, ...)?– G-Cyr
Sep 8 '17 at 15:09
mixing bootstrap margin and padding would give the 80px i guess (
p-5 m-5
). would this be compatible with other styled applied(bg, border, ...)?– G-Cyr
Sep 8 '17 at 15:09
add a comment |
2 Answers
2
active
oldest
votes
up vote
4
down vote
If you were using scss, you could simply add another entry to the $spacers variable before compiling bootstrap... so something like
$spacers: (
0: 0,
1: ($spacer * .25),
2: ($spacer * .5),
3: $spacer,
4: ($spacer * 1.5),
5: ($spacer * 3),
6: ($spacer * 5)
)
The above taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss#L100
Since it sounds like you're using CSS only, you could define your own following the pattern they do, so in your own CSS add a set of classes (see below, taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L6937):
.pt-6,
.py-6 {
padding-top: 5rem !important;
}
.pr-6,
.px-6 {
padding-right: 5rem !important;
}
.pb-6,
.py-6 {
padding-bottom: 5rem !important;
}
.pl-6,
.px-6 {
padding-left: 5rem !important;
}
and if you in particular want the medium breakpoint ones, you could do
@media (min-width: 768px) {
.pt-md-6,
.py-md-6 {
padding-top: 5rem !important;
}
.pr-md-6,
.px-md-6 {
padding-right: 5rem !important;
}
.pb-md-6,
.py-md-6 {
padding-bottom: 5rem !important;
}
.pl-md-6,
.px-md-6 {
padding-left: 5rem !important;
}
}
add a comment |
up vote
0
down vote
If you were using scss, thats my very basic extension of spacers (bootstrap 4 - default font-size:16px)
$spacer: 1rem !default;
$spacers: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$spacers: map-merge(
(
0: 0,
1: ($spacer * .25), //4px
2: ($spacer * .5), //8px
3: $spacer, //16px
4: ($spacer * 1.5), //24px
5: ($spacer * 3), //48px
6: ($spacer * 4), //64px
7: ($spacer * 5), //80px
8: ($spacer * 6.25), //100px
9: ($spacer * 7.5), //120px
10: ($spacer * 9.375) //150px
),
$spacers
This code is just a copy-paste from Bootstrap's_variables.scss
. What is the official way of completely replacining the$spacers
entries? Like when you need to add a.125
multiplier to be the first item with shifting all the others.
– Alexander Abakumov
Nov 14 at 22:08
Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
– Stavros
9 hours ago
Alright :) I've meant that when using this snippet we probably would not want to copy those!default
s. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.
– Alexander Abakumov
8 hours ago
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
If you were using scss, you could simply add another entry to the $spacers variable before compiling bootstrap... so something like
$spacers: (
0: 0,
1: ($spacer * .25),
2: ($spacer * .5),
3: $spacer,
4: ($spacer * 1.5),
5: ($spacer * 3),
6: ($spacer * 5)
)
The above taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss#L100
Since it sounds like you're using CSS only, you could define your own following the pattern they do, so in your own CSS add a set of classes (see below, taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L6937):
.pt-6,
.py-6 {
padding-top: 5rem !important;
}
.pr-6,
.px-6 {
padding-right: 5rem !important;
}
.pb-6,
.py-6 {
padding-bottom: 5rem !important;
}
.pl-6,
.px-6 {
padding-left: 5rem !important;
}
and if you in particular want the medium breakpoint ones, you could do
@media (min-width: 768px) {
.pt-md-6,
.py-md-6 {
padding-top: 5rem !important;
}
.pr-md-6,
.px-md-6 {
padding-right: 5rem !important;
}
.pb-md-6,
.py-md-6 {
padding-bottom: 5rem !important;
}
.pl-md-6,
.px-md-6 {
padding-left: 5rem !important;
}
}
add a comment |
up vote
4
down vote
If you were using scss, you could simply add another entry to the $spacers variable before compiling bootstrap... so something like
$spacers: (
0: 0,
1: ($spacer * .25),
2: ($spacer * .5),
3: $spacer,
4: ($spacer * 1.5),
5: ($spacer * 3),
6: ($spacer * 5)
)
The above taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss#L100
Since it sounds like you're using CSS only, you could define your own following the pattern they do, so in your own CSS add a set of classes (see below, taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L6937):
.pt-6,
.py-6 {
padding-top: 5rem !important;
}
.pr-6,
.px-6 {
padding-right: 5rem !important;
}
.pb-6,
.py-6 {
padding-bottom: 5rem !important;
}
.pl-6,
.px-6 {
padding-left: 5rem !important;
}
and if you in particular want the medium breakpoint ones, you could do
@media (min-width: 768px) {
.pt-md-6,
.py-md-6 {
padding-top: 5rem !important;
}
.pr-md-6,
.px-md-6 {
padding-right: 5rem !important;
}
.pb-md-6,
.py-md-6 {
padding-bottom: 5rem !important;
}
.pl-md-6,
.px-md-6 {
padding-left: 5rem !important;
}
}
add a comment |
up vote
4
down vote
up vote
4
down vote
If you were using scss, you could simply add another entry to the $spacers variable before compiling bootstrap... so something like
$spacers: (
0: 0,
1: ($spacer * .25),
2: ($spacer * .5),
3: $spacer,
4: ($spacer * 1.5),
5: ($spacer * 3),
6: ($spacer * 5)
)
The above taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss#L100
Since it sounds like you're using CSS only, you could define your own following the pattern they do, so in your own CSS add a set of classes (see below, taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L6937):
.pt-6,
.py-6 {
padding-top: 5rem !important;
}
.pr-6,
.px-6 {
padding-right: 5rem !important;
}
.pb-6,
.py-6 {
padding-bottom: 5rem !important;
}
.pl-6,
.px-6 {
padding-left: 5rem !important;
}
and if you in particular want the medium breakpoint ones, you could do
@media (min-width: 768px) {
.pt-md-6,
.py-md-6 {
padding-top: 5rem !important;
}
.pr-md-6,
.px-md-6 {
padding-right: 5rem !important;
}
.pb-md-6,
.py-md-6 {
padding-bottom: 5rem !important;
}
.pl-md-6,
.px-md-6 {
padding-left: 5rem !important;
}
}
If you were using scss, you could simply add another entry to the $spacers variable before compiling bootstrap... so something like
$spacers: (
0: 0,
1: ($spacer * .25),
2: ($spacer * .5),
3: $spacer,
4: ($spacer * 1.5),
5: ($spacer * 3),
6: ($spacer * 5)
)
The above taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/scss/_variables.scss#L100
Since it sounds like you're using CSS only, you could define your own following the pattern they do, so in your own CSS add a set of classes (see below, taken and modified from https://github.com/twbs/bootstrap/blob/v4-dev/dist/css/bootstrap.css#L6937):
.pt-6,
.py-6 {
padding-top: 5rem !important;
}
.pr-6,
.px-6 {
padding-right: 5rem !important;
}
.pb-6,
.py-6 {
padding-bottom: 5rem !important;
}
.pl-6,
.px-6 {
padding-left: 5rem !important;
}
and if you in particular want the medium breakpoint ones, you could do
@media (min-width: 768px) {
.pt-md-6,
.py-md-6 {
padding-top: 5rem !important;
}
.pr-md-6,
.px-md-6 {
padding-right: 5rem !important;
}
.pb-md-6,
.py-md-6 {
padding-bottom: 5rem !important;
}
.pl-md-6,
.px-md-6 {
padding-left: 5rem !important;
}
}
answered Sep 8 '17 at 22:01
kball
66936
66936
add a comment |
add a comment |
up vote
0
down vote
If you were using scss, thats my very basic extension of spacers (bootstrap 4 - default font-size:16px)
$spacer: 1rem !default;
$spacers: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$spacers: map-merge(
(
0: 0,
1: ($spacer * .25), //4px
2: ($spacer * .5), //8px
3: $spacer, //16px
4: ($spacer * 1.5), //24px
5: ($spacer * 3), //48px
6: ($spacer * 4), //64px
7: ($spacer * 5), //80px
8: ($spacer * 6.25), //100px
9: ($spacer * 7.5), //120px
10: ($spacer * 9.375) //150px
),
$spacers
This code is just a copy-paste from Bootstrap's_variables.scss
. What is the official way of completely replacining the$spacers
entries? Like when you need to add a.125
multiplier to be the first item with shifting all the others.
– Alexander Abakumov
Nov 14 at 22:08
Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
– Stavros
9 hours ago
Alright :) I've meant that when using this snippet we probably would not want to copy those!default
s. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.
– Alexander Abakumov
8 hours ago
add a comment |
up vote
0
down vote
If you were using scss, thats my very basic extension of spacers (bootstrap 4 - default font-size:16px)
$spacer: 1rem !default;
$spacers: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$spacers: map-merge(
(
0: 0,
1: ($spacer * .25), //4px
2: ($spacer * .5), //8px
3: $spacer, //16px
4: ($spacer * 1.5), //24px
5: ($spacer * 3), //48px
6: ($spacer * 4), //64px
7: ($spacer * 5), //80px
8: ($spacer * 6.25), //100px
9: ($spacer * 7.5), //120px
10: ($spacer * 9.375) //150px
),
$spacers
This code is just a copy-paste from Bootstrap's_variables.scss
. What is the official way of completely replacining the$spacers
entries? Like when you need to add a.125
multiplier to be the first item with shifting all the others.
– Alexander Abakumov
Nov 14 at 22:08
Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
– Stavros
9 hours ago
Alright :) I've meant that when using this snippet we probably would not want to copy those!default
s. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.
– Alexander Abakumov
8 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
If you were using scss, thats my very basic extension of spacers (bootstrap 4 - default font-size:16px)
$spacer: 1rem !default;
$spacers: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$spacers: map-merge(
(
0: 0,
1: ($spacer * .25), //4px
2: ($spacer * .5), //8px
3: $spacer, //16px
4: ($spacer * 1.5), //24px
5: ($spacer * 3), //48px
6: ($spacer * 4), //64px
7: ($spacer * 5), //80px
8: ($spacer * 6.25), //100px
9: ($spacer * 7.5), //120px
10: ($spacer * 9.375) //150px
),
$spacers
If you were using scss, thats my very basic extension of spacers (bootstrap 4 - default font-size:16px)
$spacer: 1rem !default;
$spacers: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$spacers: map-merge(
(
0: 0,
1: ($spacer * .25), //4px
2: ($spacer * .5), //8px
3: $spacer, //16px
4: ($spacer * 1.5), //24px
5: ($spacer * 3), //48px
6: ($spacer * 4), //64px
7: ($spacer * 5), //80px
8: ($spacer * 6.25), //100px
9: ($spacer * 7.5), //120px
10: ($spacer * 9.375) //150px
),
$spacers
answered Nov 10 at 22:07
Stavros
32
32
This code is just a copy-paste from Bootstrap's_variables.scss
. What is the official way of completely replacining the$spacers
entries? Like when you need to add a.125
multiplier to be the first item with shifting all the others.
– Alexander Abakumov
Nov 14 at 22:08
Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
– Stavros
9 hours ago
Alright :) I've meant that when using this snippet we probably would not want to copy those!default
s. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.
– Alexander Abakumov
8 hours ago
add a comment |
This code is just a copy-paste from Bootstrap's_variables.scss
. What is the official way of completely replacining the$spacers
entries? Like when you need to add a.125
multiplier to be the first item with shifting all the others.
– Alexander Abakumov
Nov 14 at 22:08
Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
– Stavros
9 hours ago
Alright :) I've meant that when using this snippet we probably would not want to copy those!default
s. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.
– Alexander Abakumov
8 hours ago
This code is just a copy-paste from Bootstrap's
_variables.scss
. What is the official way of completely replacining the $spacers
entries? Like when you need to add a .125
multiplier to be the first item with shifting all the others.– Alexander Abakumov
Nov 14 at 22:08
This code is just a copy-paste from Bootstrap's
_variables.scss
. What is the official way of completely replacining the $spacers
entries? Like when you need to add a .125
multiplier to be the first item with shifting all the others.– Alexander Abakumov
Nov 14 at 22:08
Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
– Stavros
9 hours ago
Hey Alexander, this code is an extent via official way to answer the question "I would like to create one more option in the bootstrap spacers.". The basic bootstrap goes up to 5. Same logic goes to your question as well. Change all the values and start 1 from .125, 2 for .25 etc
– Stavros
9 hours ago
Alright :) I've meant that when using this snippet we probably would not want to copy those
!default
s. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.– Alexander Abakumov
8 hours ago
Alright :) I've meant that when using this snippet we probably would not want to copy those
!default
s. AFAIK, we should remove them when copy-pasting BS stuff into our SCSS.– Alexander Abakumov
8 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46119384%2fbootstrap-4-add-more-sizes-spacing%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
mixing bootstrap margin and padding would give the 80px i guess (
p-5 m-5
). would this be compatible with other styled applied(bg, border, ...)?– G-Cyr
Sep 8 '17 at 15:09