Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !6801

Add rem as default unit for font-sizes, including fallback

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/drublic/rem-font-size into 3.0.0-wip Feb 05, 2013
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 18

Created by: drublic

This PR is against the 3.0.0-wip branch.

In #6342 one of the issues still open is the use of the CSS unit rem. Using rem is supported in all relevant browsers except Internet Explorer 8 and below.

It is fairly easy to write a mixin which provides a pixel-based fallback for properties using rem. I wrote about this some weeks ago but the technique is not exactly new.

This commit adds a simple mixin which calculates a pixel based value for font-sizes based on a provided rem-value. As described in the post, it is possible to interpolate property names and write a rem-fallback for all properties but in this case I sticked to font-size.

Including the mixin in LESS works like this:

.rem-font-size(@size) // while @size is a unit-less number

The @size-variable is based on the root-font-size of the website – which is 10px in the case of Bootstrap (aka. 62.5%).

This commit also changes all font-sizes from px-based values to the usage of the rem-size fallback.

Later next month (aaaahm– year, decade… whatever) when Bootstrap will drop support for IE8 it is really easy to switch to a rem-only font-size by running a grep|sed with a regex and all.

The thing that bugs be a little about this PR is using of the unit()-function to calculate a proper base font-size for the main elements (which use @font-size-base).

To be honest I would consider rethinking the font-size situation and maybe build the rem values upon the default font-size of 14px (this would mean applying it to the root-element (which is html)). An advantage at the moment is the calculating of rem-values (which is dividing the px-based font-size by 10). That could be a point against changing the root-font-size.

Well… This is open for discussion and I am willing to update the PR if necessary.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/drublic/rem-font-size