CSS web layout is difficult, but it is actually very simple. It is easy to say, and often there are many problems that bother novices. In this article, many tips and knowledge can help you with twice the result with half the effort. However, more often, we are often entangled by some small problems and cannot relax. Today I will introduce you to eight tips, which seem very useful. 2. When using the floating function, remember to properly clear the floating command. It is a dangerous function and may not produce the results you expect. If you encounter a floating element extending to the border of the peripheral container or other abnormal situations, make sure that you are correct first. 3. Use padding or border when boundaries overlap to avoid you being overwhelmed by a little space that shouldn't appear, or you can't squeeze out when you need a little space. If you use margin, it is easy to produce overlaps in boundaries. 4. Try to avoid the calculation problems of width and height that specify padding/border to elements at the same time and height or width. Some methods can solve this problem, but if the parent element needs to specify height and width, it is best to apply margin to the child element within the parent element, or when the child element needs to specify height and width, apply padding to the parent element to achieve Effect. 5. Don't rely on min-width/min-height 6. If you have any questions, reduce the percentage first. Sometimes some errors will make 50%+50% 100.1%, causing problems with the web page. At this time, please try to change these values to 49%, or even 49.9%. 7. Remember the word "TRBL" border. The abbreviation syntax of margin and padding has a specific order. Start from above and turn clockwise: top, right, bottom, left. So margin:0 1px 3px 5px; the result is that there is no boundary above. , 1 pixel to the right, and so on. Remember "TRBL" and you won't get the order wrong. 8. As long as the value is not zero, you must specify the unit. This requires special attention. Many novices often ignore this issue.
1. If you have any questions, immediately detect it. If you can simply detect the original code when something goes wrong, you can save a lot of headaches. W3C has detection tools available for XHTML and CSS, see http://validator.w3.org. Please note that errors at the beginning of the file may cause more errors due to factors such as improper structure; we recommend correcting some of the most obvious errors before re-detection, which may reduce the number of errors.
IE on Windows does not support two syntaxes. But to a certain extent, the Windows version of IE can achieve the effect equivalent to min-width/min-height, so just do some filtering function on IE to achieve the results you want.