Hey guys i have a small issue with resizing fonts according to screen size. Im using Bootstrap 3 and LESS.
here is what i have a the top of my less code:
@font-size-base: 16px;
@font-size-large: ceil((@font-size-base * 1.25)); // ~18px
@font-size-small: ceil((@font-size-base * 0.85)); // ~12px
@font-size-h1: floor((@font-size-base * 2.3)); // ~36px
@font-size-h2: floor((@font-size-base * 2.15)); // ~30px
@font-size-h3: ceil((@font-size-base * 1.35)); // ~24px
@font-size-h4: ceil((@font-size-base * 1.25)); // ~18px
@font-size-h5: @font-size-base;
@font-size-h6: ceil((@font-size-base * 0.85)); // ~12px
so far so good. After that i have the following:
h1.pageTitle {
font-family: @font-family-sans-serif;
font-size: @font-size-h1;
font-weight: 300;
color: #2aace3;
text-align: center;
margin-bottom: 20px;
text-transform: uppercase;
}
h2 {
font-family: @font-family-sans-serif;
font-size: @font-size-h2;
font-weight: 300;
text-align: center;
}
h3 {
font-family: @font-family-sans-serif;
font-size: @font-size-h3;
font-weight: 300;
}
h4 {
color: #555;
font-size: @font-size-base;
}
p, .button, li {
font-family: @font-family-sans-serif;
font-size: @font-size-base;
font-weight: 300;
margin: 0 0 0px;
line-height: @line-height-base;
}
at the end of the LESS file i have:
@media (min-width: @screen-sm-min) {
@font-size-base: 22px !important;
@font-size-large: ceil((@font-size-base * 1.25)) !important; // ~18px
@font-size-small: ceil((@font-size-base * 0.85)) !important; // ~12px
@font-size-h1: floor((@font-size-base * 2.6)) !important; // ~36px
@font-size-h2: floor((@font-size-base * 2.15)) !important; // ~30px
@font-size-h3: ceil((@font-size-base * 1.7)) !important; // ~24px
@font-size-h4: ceil((@font-size-base * 1.25)) !important; // ~18px
@font-size-h5: @font-size-base !important;
@font-size-h6: ceil((@font-size-base * 0.85)) !important; // ~12px
}
Everything works as it should no problems at all. however i've added just above the media query that checks min screen size the following code:
#course-info {
#accordion {
.panel {
border: none;
box-shadow: none;
.panel-heading {
background: #fff;
border-bottom: 1px solid #e6e6e6;
h3 {
font-size: @font-size-h3;
}
}
}
}
}
For some reason i can't explain the H3 tag inside the #accordion code is picking up the base-font size from the top of the file which according to bootstrap laws should be for xs screen sizes, even tho i'm looking at it on a browser.
The reason i need to do this is because i'd like to resize the H3 value on that tag to something else so in the end i'd have something like:
#course-info {
#accordion {
.panel {
border: none;
box-shadow: none;
.panel-heading {
background: #fff;
border-bottom: 1px solid #e6e6e6;
h3 {
ceil((@font-size-h3 * 0.85)) !important;
}
}
}
}
}
If i change the base value inside the media query the entire text of the page changes but those specific H3 tags. Can someone explain to me what is going on?
cheers, dan