HTML5 responsive layout basics (1)
HTML5 responsive layout (1)
The layout method of mobile terminal development-fluid layout
The first time you encounter the concept of fluid layout, you will think that this concept is very high-end, but after a deeper understanding, you will find that it is actually very simple. For those who have experience in HTML desktop web development, in fact, fluid layout is Changed some hard-coded layouts on the desktop to percentages to adapt to various mobile sizes.
Flow layout can also be called percentage layout in layman’s terms, which usually includes the following points:
-
Width percentage
#Positioning percentage
Replace px with em, and rem
Elastic picture The reference object for setting these percentages is adapted according to the screen size of the mobile phone, and a certain effect is achieved through size adaptation.
#Why do you need to use fluid layout? Adapt to mobile terminal?
#Fixed pixel size web pages are the easiest way to match fixed pixel size displays. But this method is not a fully compatible production method for future web pages. We need some methods to adapt to unknown devices. Fixed pixel sizes (960/980) are not future proof.
#How to use percentages to layout page? Size percentage: Modify the web page from fixed layout to percentage layout: Required Formula to remember: target element width / context element width = percentage width. #PS: The width of the context element here refers to the width of the parent element associated with it, which will directly affect the width percentage of the child element. Position percentage: is basically similar to the size percentage, that is, the original fixed margin or Positioning distance converted into percentage For example: With the left side of the page 50px and the context width 320px, that is 50/320=15.625% Reserve 5 decimal point. ##em: The function of em is generally to set the font size, set a standard font size in its parent, and control the percentage of the font through em. The value of em is not fixed; #em will inherit the font size of the parent element.
##rem: Although em can realize the percentage display of fonts and change the font size in proportion according to the screen size, once structural nesting occurs during the actual development process, the parent font will When the proportion changes, the font of the child element will change proportionally according to the change of the parent's font. If em is used to change the font, the calculation amount will be very large, which will inevitably cause a certain burden on development. A new unit rem was introduced in css3, which will only change based on HTML tags. rem stands for root em, and the root of em is html, which means the proportion changes only based on html. ##Flexible image: Image settings width:100%, or background-size:100% 100%. Picture setting threshold: max-width. can set the maximum and minimum values of the picture. Of course, fluid layout is only a way to adapt to mobile terminals, and it cannot achieve the effect of responsive web pages. Later, I will introduce to you another adaptation method called media query. Only by combining the two adaptation methods can the final responsive layout effect be achieved.

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

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.
