我正在制作一个Bootstrap网站。虽然在所有屏幕尺寸上都可以正常工作,但标题(h1)的大小保持不变。 对于小屏幕来说,它太大了。 我应该如何固定Bootstrap的h1或标题?
@media
实现此功能。@media screen and (max-width: 768px) {
h1{
font-size:14px;
}
}
这意味着在小于768像素的尺寸下,h1标签的字体大小将是14像素。
你可以使用类似的方式设置所需的所有像素。
@import "bootstrap/scss/functions.scss";
@import "bootstrap/scss/variables.scss";
@import "bootstrap/scss/mixins.scss";
@each $breakpoint in map-keys($grid-breakpoints) {
@include media-breakpoint-up($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
.h1#{$infix} { font-size: $h1-font-size!important; }
.h2#{$infix} { font-size: $h2-font-size!important; }
.h3#{$infix} { font-size: $h3-font-size!important; }
.h4#{$infix} { font-size: $h4-font-size!important; }
.h5#{$infix} { font-size: $h5-font-size!important; }
.h6#{$infix} { font-size: $h6-font-size!important; }
.display-1#{$infix} {
font-size: $display1-size!important;
font-weight: $display1-weight;
line-height: $display-line-height;
}
.display-2#{$infix} {
font-size: $display2-size!important;
font-weight: $display2-weight;
line-height: $display-line-height;
}
.display-3#{$infix} {
font-size: $display3-size!important;
font-weight: $display3-weight;
line-height: $display-line-height;
}
.display-4#{$infix} {
font-size: $display4-size!important;
font-weight: $display4-weight;
line-height: $display-line-height;
}
}
}
最好在你自己的Sass中使用Bootstrap Sass,保持DRY和可维护性。
@import "../bootstrap-sass/bootstrap/variables";
@media screen and (max-width: $screen-md-max) {
h1 {
font-size:14px;
}
}