[Translation] CSS and HTML design patterns Chapter 1 design patterns: Making CSS easier (1)

Source: Internet
Author: User

Chapter 1 design pattern: Making CSS easier

On the surface, CSS seems easy. It has 45
Commonly used properties you can employ to style a document. below the surface,
Different combinations of properties and property values trigger completely
Different results. I call this CSS polymorphism because the same property has alias
Meanings. The result of CSS polymorphism is a combinatorial explosion
Possibilities.

CSS is not difficult on the surface. The 45 commonly used attributes are enough for style-based documents. Otherwise, different combinations of attributes and attribute values will produce very different results. I call it CSS polymorphism-because the same attributes have different meanings. CSS polymorphism results in a surge in combinations of various possibilities.

Learning CSS is more than learning about individual properties. It is about learning
Contexts in which properties can be used and how different types of property values work differently
In each context. As an example, take the width property, which has different
Meanings depending on how it is combined with other rules and what values are assigned
It. For instance, width has absolutely no effect on inlines. Width: auto shrinkwraps floats
The width of their content. Width: auto shrinkwraps absolutes when left and right are set
Auto. Width: auto stretches blocks to the width of their parent element. Width: auto stretches
Absolutes to the width of their containing block when left and right are set to 0. Width: 100%
Stretches blocks and floats to the width of their parent element as long as they do not have
Borders, padding, and margins. Width: 100% stretches tables to the width of their parent even if
They do have borders and padding. Width: 100% stretches absolutes To the width of their closest
Positioned ancestor instead of their parent. Width: 100em sizes an element in relation to
Height of Its font-size, which allows the element to be sized wide enough to contain a certain
Number of characters. Width: 100px sizes an element to a fixed number of pixels regardless
The font-size of its text.
Learning CSS not only learns its individual attributes. We also need to learn the environment of the attribute used and how different types of attribute values work in different environments. Different meanings depend on how it is combined and assigned with other rules. Let's take the width attribute as an example. Width is definitely invalid in the row. Width: auto will scale down the float to the width of its content. Width: auto sets the value of left and right to auto. Width: auto will open the block to the width of its parent element. Width: auto will open the absolute positioning until the left and right values of the contained blocks are set to 0. Width: 100% will open the block and floating to the width of its parent element, instead of having borders, fills, and margins. Width: 100% extend the table to the width of its parent element, even if they have borders and fill. Width: 100% will open the absolute positioning to the width of the ancestor element in the nearest position, rather than the width of its parent element. Width: 100em indicates that the size of an element is the height relative to its font-size, so that the size range of the element can include a certain number of words. Width: 100px makes the element size a fixed Image value regardless of the font-size of the text.
To complicate matters further, not all of the rules are implemented by browsers.
Example, over 40 out of 122 properties and over 250 out of 600 CSS rules are not implemented by one or more of the major browsers.

Things will become more complex in the future, but not all rules can be implemented on browsers. For example, 40 to 122 attributes and 250 to 600 CSS rules cannot be implemented in more than one mainstream browser.

Trying to learn
CSS by memorizing the extraordinary number of exceptions to each rule is extremely
Frustrating.

If you want to learn to remember each of the rules on which CSS is biased, you will lose.

To make learning
CSS easy, this book documents ents all usable combinations of properties and
Property values. It puts properties in context and paints a complete picture
How CSS works.


CSS wants to learn more easily. This book combines all available attributes and their values. It places attributes in the context and shows you how CSS works like a complete painting.

Imagine
Time you will save by not having to read about rules that do not work and by not
Having to test every rule to see whether it works in every browser and in
Combination with other rules. I have already done this for you. I have run tables
Thousands of tests. I have tested every CSS property and every combination
Properties in every major browser including Internet Explorer 7, Internet
Explorer 6, Firefox 2, opera 9, and Safari 2.

Imagine that you have not read the relevant rules and cannot work to test that each rule operates on each browser and works with other rules. I have prepared everything for you. Thousands of tests have been conducted. Each CSS attribute and its attributes have been tested in various mainstream browsers, including Internet Explorer 7,
Internet Explorer 6, Firefox 2, opera 9, and Safari 2.
I have boiled down these results into 350 + simple design patterns-all the CSS and HTML design patterns you need to create stunning, high-performance, and accessible web sites.
This book has more than 350 CSS and HTML design patterns, allowing you to create highly attractive, high-performance, and available websites.
After you learn these design patterns, you'll wonder how you ever developed web sites without them!
Later, you will learn these design patterns and will feel incredible that you have never used a website.
In this chapter, I discuss the purpose of design patterns and how they work. I give some examples of how to combine design patterns to create new patterns. I also discuss how to use stylesheets, CSS syntax, And the cascading order to your advantage.
In this section, we will discuss the purpose of the design model and how it works. Some examples show you how to create a new mode in combination with the design mode. We will also discuss how to use the advantages of style sheets, CSS syntax, and stacked order.
Next, I present a series of charts that list all the usable CSS properties and units of measure. I then present 12 techniques for troubleshooting CSS quickly. lastly, I discuss how to standardize the way varous browsers style elements-so you can override these default styles with confidence.
The following is a list of all available CSS attributes and measurement units. Then there are 12 CSS quick solutions. At the end of the article, we will discuss how to standardize the methods of various Browser style elements-you can ignore the feelings of those default styles.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.