Fluid Responsive CSS Font Size: Difference between revisions
Line 78: | Line 78: | ||
== CSS for Fluid == | == CSS for Fluid == | ||
A {{FormFCTW|8|blue|bold|minimum font size}} property is missing in CSS. But... | A {{FormFCTW|8|blue|bold|minimum font size}} property is missing in CSS. But... | ||
Revision as of 10:16, 10 August 2023
Introduction
Making Responsive Websites is not easy. Many examples are just made for just one part of the problem and seldom on the entire problem. Let me try to help, by creating this page, which is, of course, at-the-moment under construction.
Summary
Embracing fluid typography might be easier than you think. It has wide browser support, is simple to implement and can be achieved without losing control over many important aspects of design.
Viewport
Text | Code Javascript + jQuery |
---|---|
Viewport units making fluid typography on the web possible.
Viewport units refer to a percentage of the browser’s viewport dimensions.
|
## What is viewport's height and width using JS $ console.log( "Viewport vh x vh : " + window.innerHeight + "px x " + window.innerWidth + "px" ) ## Result in (not your real viewport, just an example): Viewport vh x vh : 836px x 1638px |
Viewport unit | Description |
---|---|
vw | Viewport width, equivalent to JS window.innerWidth |
vh | Viewport height, equivalent to JS window.innerHeight |
vmin | Smaller value of the viewport’s width and height |
vmax | Larger value of the viewport’s width and height |
Text | Code Javascript + jQuery |
---|---|
Easiest way to start fluid typography is to set the font-size on an html element.
|
html { font-size: 2vw; } |
A heading size of 2em is now equivalent to 4vw because this is twice the current font size of 2vw.
Using viewport-relative units alone comes with some drawbacks :
Luckily, there are ways to overcome all of these limitations. |
h1 { font-size: 2em; } |
CSS for Fluid
A minimum font size property is missing in CSS. But...
See also
Reference
- ↑ Smashing Magazine, 2016 Fluid Typography, an article by Michael Riethmuller.