When making a web page, we usually need to consider issues such as different computer screen sizes and different mobile phone screen sizes, and solve the problem of style changes. So how do we solve this problem? Now we mainly use adaptation to solve the problems of height, width, and picture adaptation. Let's summarize it on PC and mobile terminals. Usually, when adaptive height and width are performed, and pictures are generally related to the layout of the page. 1. The minimum resolution is 1024*768 (traditional 17-inch monitor), then 940px, 960px, or the commonly used 980px can be used as the minimum width 2. The next larger resolution after 1024*768 is 1280*768, so you can use 1200px or 1220px as the larger webpage width 3. Advanced browsers that support css3 and html5 can use CSS3 Media Queries to allow web pages to automatically adjust layout tags at different resolutions 4. For browsers that do not support css3 and html5, especially those <= ie8 series, you need to use js and resize events to control the width of html layout tags. 5. Width adaptation requires calculation of different widths for each display module, which requires a lot of calculation and adaptation when doing HTML layout. 6. Width Adaptation Commonly used CSS when writing layout elements for different width displays Next, let’s see how to use js and css to adapt to the size of the screen. One: Understand the basics of height and width Here are some pictures to illustrate: The height and width of the visible area of the web page are: document.body.clientHeight||document.body.clientWidth The height and width of the web page body area are: document.body.scrollHeight||document.body.scrollWidth (including the length of the scroll wheel) The upper left area of the web page that is scrolled away: document.body.scrollTop||document.body.scrollLeft Two: css adaptive height 1. Two-column layout, fixed on the left and adaptive on the right XML/HTML Code copy content to the clipboard
2. Three-column layout, fixed width on both sides, adaptive width in the middle
to copy XML/HTML Code content to the clipboard :
3. Regarding the minimum width and maximum width , we still look at it in conjunction with the layout, such as the following code: adaptive width, thereby changing the layout. XML/HTML CodeCopy the content to the clipboard
Understand what minimum width and maximum width are. The minimum width refers to the minimum width set for an element. After reaching the minimum width, scaling the text will not have any effect . The maximum width is an upper limit that all elements can reach and cannot be increased any further. Three: CSS handles adaptive height XML/HTML CodeCopy the content to the clipboard
parent level changes adaptively with child level height and child level changes with parent level height XML/HTML CodeCopy content to clipboard
If the child div uses the float attribute, it has already left the standard flow, and the parent div will not change with the height of the content. The solution is to add an empty div under the floating div and set the clear attribute both XML/HTML CodeCopy content to clipboard
There are many other methods for height adaptation, which are not listed here. Like height:auto and so on. Four: js handles height and width adaptation issues XML/HTML CodeCopy content to clipboard
Width adaptive code: XML/HTML CodeCopy content to clipboardfunction
Five: Adaptive height and width of mobile terminals The mobile terminal is relatively simpler. First, add a line of viewport tags to the head of the web page code. <meta name=”viewport” content=”width=device-width, initial-scale=1″ /> viewport is the default width and height of the web page. The above means that the width of the web page is equal to the width of the device screen by default, and the original scaling ratio is 1, that is, the initial size of the web page occupies 100% of the screen area. 1: Since the web page will adjust the layout according to the screen width, you cannot use an absolute width layout or elements with absolute width. This one is very important. : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : The above quick solution to the adaptation problem between PC and mobile terminals is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. |
<<: HTML basics HTML structure
>>: Several situations that cause MySQL to perform a full table scan
Table of contents background: need: Effect 1. Ide...
1. Background In the context of rapid updates and...
What is JConsole JConsole was introduced in Java ...
Definition and Use Using @media queries, you can ...
Sometimes you need to access some static resource...
SVG has been widely used in recent years due to i...
What is a table? Table is an Html table, a carrie...
Achieve results Implementation Code html <div ...
I have roughly listed some values to stimulate ...
Windows Server 2008 server automatically restarts...
For example, he enters: XML/HTML Code div#page>...
Table of contents What is multi-environment confi...
CSS Viewport units have been around for the past ...
sudo configuration file The default configuration...
In more and more websites, the use of XHTML is rep...