Home>Article>Web Front-end> How HTML automatically adapts web design to screen width

How HTML automatically adapts web design to screen width

零到壹度
零到壹度 Original
2018-03-21 11:17:09 13456browse

Today’s article mainly talks about how HTML automatically adapts web design to the screen width. Friends who need it can refer to it. I hope it can help everyone.

Allow web page width to adjust automatically

How does "adaptive web design" work? It's not that difficult.

First, add a line ofviewport meta tagat the head of the web page code.

##viewportis the default width and height of the web page. The above line of code means that the width of the web page is equal to the screen width by default (width=device-width), and the original scaling ratio (initial-scale=1) is 1.0, that is, the initial size of the web page occupies the screen 100% of the area.

All major browsers support this setting, including IE9. For those older browsers (mainly IE6, 7, and 8), you need to use

css3-mediaqueries.js.

Do not use absolute width

Because the web page will adjust the layout according to the screen width, absolute width cannot be used The layout also cannot use elements with absolute width. This one is very important.

Specifically, CSS code cannot specify pixel width:

width:xxx px;Only percentage width can be specified:width: xx%; orwidth:auto;

##Related recommendations:

Web page adaptive screen width

HTML5 responsive (adaptive) web design

How to make a web page that adapts to the screen size from

The above is the detailed content of How HTML automatically adapts web design to screen width. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn