Koyarwar CSS

Koyarwar CSS

CSS has several different units to represent length.

Many CSS properties accept 'length' values such as width,margin,padding,font-size etc.

Length is a number followed by a length unit, such as 10px,2em etc.

Example

Use px (pixels) to set different length values:

h1 {
  font-size: 60px;
}
p {
  font-size: 25px;
  line-height: 50px;
}

Try it yourself

There should be no spaces between numbers and units. However, if the value is 0, the unit can be omitted.

For some CSS properties, negative lengths are allowed.

There are two types of length units:Absolute unitsandRelative units.

Absolute length

Absolute length units are fixed, and the length represented by any absolute length will be displayed exactly this size.

It is not recommended to use absolute length units on the screen because the screen size varies greatly. However, if the output medium is known, they can be used, such as for print layout (print layout).

unit ba'a TIY
cm Centimeter آموزش:
mm Millimeter آموزش:
in Inch (1in = 96px = 2.54cm) آموزش:
px * Pixel (1px = 1/96th of 1in) آموزش:
pt Point (1pt = 1/72 of 1in) آموزش:
pc Pica (1pc = 12 pt) آموزش:

* Pixel (px) is relative to the viewing device. For low dpi devices, 1px is one device pixel (dot) on the screen. For printers and high-resolution screens, 1px represents multiple device pixels.

Relative length

Relative length units define the length relative to another length property. Relative length units scale better across different rendering media.

unit ba'a TIY
em koyi na tsa 'font-size' na element (2em ni kai wuri 'font-size' na aya 2 times) آموزش:
ex koyi na tsa x-height na aya na baiwa (kai koyi kai kai kai) آموزش:
ch koyi na tsa '0' (zeru) آموزش:
rem koyi na tsa 'font-size' na root element آموزش:
vw koyi na tsa 1% na kiyari na kofarinso آموزش:
vh koyi na tsa 1% na kiyari na kofarinso آموزش:
vmin koyi na tsa 1% na kiyari na kofarinso آموزش:
vmax * بزرگ‌تر از 1% از ویندوز دید* آموزش:
% مقابل عنصر والد آموزش:

توجه:واحدهای em و rem می‌توانند برای ایجاد یک طراحی قابل انعطاف کامل استفاده شوند!

* ویندوز دید (Viewport) = اندازه پنجره مرورگر. اگر ویندوز دید 50 سانتی‌متر عرض داشته باشد، 1vw = 0.5 سانتی‌متر.

پشتیبانی مرورگر

اعداد در جدول نشان‌دهنده نسخه اولین مرورگر هستند که از این واحد پشتیبانی می‌کند.

واحدهای طول
em, ex, %, px, cm, mm, in, pt, pc 1.0 3.0 1.0 1.0 3.5
ch 27.0 9.0 1.0 7.0 20.0
rem 4.0 9.0 3.6 4.1 11.6
vh, vw 20.0 9.0 19.0 6.0 20.0
vmin 20.0 12.0 19.0 6.0 20.0
vmax 26.0 16.0 19.0 7.0 20.0