This article brings you a summary of CSS units (such as rem, px, em, vw, vh, vm) and introduces the differences between these units. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
px: pixel (pixel) relative length unit, relative to the screen display resolution;
em: em The value is not fixed and will be integrated with the font size of the parent element;
Note:
1. Select body and declare Font-size=62.5%;
2. Divide the original px value by 10, and then replace it with em as the unit;
3. Recalculate the em value of the enlarged fonts. Avoid repeated declarations of font sizes.
The default font size of any browser is 16px. All unadjusted browsers comply with 1em=16px, 0.75em=12px, and 10px=0.625em. In order to simplify the conversion of Font-size, you need to declare Font-size=62.5% in the body selector in CSS, which makes the value of em become 16px*62.5%=10px, so 12px is 1.2em and 10px is 1em. That is, just divide the original px value by 10 and replace it with the unit of em.
rem: Relative unit, (root em is rem). When using rem as the unit to set the font size, it is relative to the size of the HTML root element, which can be proportional to the root element. Modify and adjust all font sizes. Generally, they are written on the body or html. For example:
body{font-size:625%;}
, which is 1rem=100px;
, but it is best to match it when writing projects. Media queries together, for example:
html{font-size:10px} //10px==62.5% @media screen and (min-width:321px) and (max-width:375px){html{font-size:11px}} @media screen and (min-width:376px) and (max-width:414px){html{font-size:12px}} @media screen and (min-width:415px) and (max-width:639px){html{font-size:15px}} @media screen and (min-width:640px) and (max-width:719px){html{font-size:20px}} @media screen and (min-width:720px) and (max-width:749px){html{font-size:22.5px}} @media screen and (min-width:750px) and (max-width:799px){html{font-size:23.5px}} @media screen and (min-width:800px){html{font-size:25px}}
vw: The maximum width of the viewport, 1vw=one percent of the viewport width;
vh: The maximum height of the viewport, 1vh = one percent of the viewport height;
vmin/vm: The smaller of the width or height relative to the viewport. The smallest one is divided into 100 units of vmin (i.e. vm).
Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study. For more related tutorials, please visit CSS Video Tutorial!
Related recommendations:
php public welfare training video tutorial
The above is the detailed content of Summary of CSS units (such as rem, px, em, vw, vh, vm). For more information, please follow other related articles on the PHP Chinese website!

Here's a container with some child elements:

Flyout menus! The second you need to implement a menu that uses a hover event to display more menu items, you're in tricky territory. For one, they should

"The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect."- Tim Berners-Lee

In this week's roundup: datepickers are giving keyboard users headaches, a new web component compiler that helps fight FOUC, we finally get our hands on styling list item markers, and four steps to getting webmentions on your site.

The short answer: flex-shrink and flex-basis are probably what you’re lookin’ for.

In this week's look around the world of web platform news, Google Search Console makes it easier to view crawled markup, we learn that custom properties

The IndieWeb is a thing! They've got a conference coming up and everything. The New Yorker is even writing about it:


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version
SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6
Visual web development tools