Nested div elements allow you to define more CSS rules to control presentation. For example, you can give #navcontainer a rule to center the list on the right, #globalnav a rule to center the list on the left, and #subnav a rule to center the list on the left. list another completely different performance. Replace traditional methods with CSS The following list will help you replace traditional methods with CSS: HTML attributes and corresponding CSS methods HTML attribute CSS method description align="left" align="right" float: left; float: right; Use CSS to float any element: pictures, paragraphs, divs, titles, tables, lists, etc. When you use the float attribute, you must give This floated element defines a width. marginwidth="0" leftmargin="0" marginheight="0" topmargin="0" margin: 0; Using CSS, margin can be set on any element, not just the body element. More importantly, you can Specify the margin values of the top, right, bottom and left elements respectively. vlink="#333399" alink="#000000" link="#3333FF" a:link #3ff; a:visited: #339; a:hover: #999; a:active: #00f; In HTML, the color of the link is defined as an attribute value of the body. The link style is the same throughout the page. Using CSS selectors, link styles can be different in different parts of the page. bgcolor="#FFFFFF" background-color: #fff; In CSS, the background color can be defined for any element, not just body and table elements. bordercolor="#FFFFFF" border-color: #fff; Any element can set a border (boeder), you can define top, right, bottom and left respectively border="3" cellspacing= "3" border-width: 3px; Using CSS, you can define the border of the table to have a unified style, or you can define the color, size and style of the top, right, bottom and left borders respectively. You can use table, td or th selectors. If you need to set a borderless effect, you can use CSS definition: border-collapse: collapse;
clear: left; clear: right; clear: both; Many 2-column or 3-column layouts use the float attribute for positioning. If you define a background color or background image in the floating layer, you can use the clear attribute. cellpadding="3" vspace="3" hspace="3" padding: 3px; with CSS , any element can set the padding attribute. Similarly, padding can be set to top, right, bottom and left respectively. padding is transparent. align="center" text-align: center; margin-right: auto; margin-left: auto; Text-align only applies to text. Blocks like div and p Level margins can be horizontally centered through margin-right: auto; and margin-left: auto; Some regrettable techniques and working environments Due to the imperfect browser support for CSS, we sometimes have to Use some techniques (hacks) or create an environment (Workarounds) to let CSS achieve the same effect as traditional methods. For example, block-level elements sometimes need to use horizontal centering techniques, box model bug techniques, etc. All of these techniques are detailed in Molly Holzschlag’s article Integrated Web Design: Strategies for Long-Term CSS Hack Management. Another resource site for CSS tips is Big John and Holly Bergevin’s “Position is Everything
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