Thursday, 11 January 2018

Em- Web Designing

Em

Incorporating relative sizing starts by using units other than pixels. One unit of measurement you can use in CSS to create relatively-sized content is the em, written as em in CSS.
Historically, the em represented the width of a capital letter M in the typeface and size being used. That is no longer the case.
Today, the em represents the size of the base font being used. For example, if the base font of a browser is 16 pixels (which is normally the default size of text in a browser), then 1 em is equal to 16 pixels. 2 ems would equal 32 pixels, and so on.
Let's take a look at two examples that show how em can be used in CSS.
.heading { font-size: 2em; }
In the example above, no base font has been specified, therefore the font size of the headingelement will be set relative to the default font size of the browser. Assuming the default font size is 16 pixels, then the font size of the heading element will be 32 pixels.
.splash-section { font-size: 18px; } .splash-section h1 { font-size: 1.5em; }
The example above shows how to use ems without relying on the default font size of the browser. Instead, a base font size (18px) is defined for all text within the splash-section element. The second CSS rule will set the font size of all h1 elements inside of splash-section relative to the base font of splash-section (18 pixels). The resulting font size of h1 elements will be 27 pixels.
Share:

Relative Measurements

Relative Measurements

Modern technology allows users to browse the Internet via multiple devices, such as desktop monitors, mobile phones, tablets, and more. Devices of different screen sizes, however, pose a problem for web developers: how can we ensure that a website is readable and visually appealing across all devices, regardless of screen size?
The answer: responsive design! Responsive design refers to the ability of a website to resize and reorganize its content based on:
  1. The size of other content on the website.
  2. The size of the screen the website is being viewed on.
In this lesson, we'll size HTML content relativeto other content on a website.
You've probably noticed the unit of pixels, or px, used in websites. Pixels are used to size content to exact dimensions. For example, if you want a div to be exactly 500 pixels wide and 100 pixels tall, then the unit of px can be used. Pixels, however, are fixed, hard codedvalues. When a screen size changes (like switching from landscape to portrait view on a phone), elements sized with pixels can appear too small, overflow the screen, or become completely illegible.
With CSS, you can avoid hard coded measurements and use relative measurementsinstead. Relative measurements offer an advantage over hard coded measurements, as they allow for the proportions of a website to remain intact regardless of screen size or layout.
Share: