Small CSS knowledge that is often ignored by you, and small CSS knowledge that is ignored

Source: Internet
Author: User

Small CSS knowledge that is often ignored by you, and small CSS knowledge that is ignored

1. The color attribute of CSS is not only used for text display.

We believe that all Web developers have used the color attribute of CSS. If you are not a special manager

As a programmer, I believe you may not know that color attributes can be used in addition to text display and other places. It

You can change the color of all things on the page. For example:

The alt text of images that cannot be displayed, the border of the list element, the dot before the unordered list element, the number before the ordered list element, and the hr element.


<Span style = "font-size: 14px;"> 1: 

See the figure below:

 

2. The visibility attribute in CSS has a collapse attribute value: collapse

 

I believe you have used the visibility attribute in CSS for several hundred times. Most of the time, you will set its value

To visible (this is the default value for all page elements) or hidden. The latter is equivalent to display: none, but still

However, the page space is occupied. In fact, visibility can have a third value, namely collapse.




3. New attribute values are added in the background shorthand for CSS.

In CSS2.1, the abbreviated background attribute includes five attribute values: background-color and background-

Image, background-repeat, background-attachment, and background-position. Three new attribute values have been added since CSS3. A total of eight values are added. The following are the meanings in order:

Background: [background-color] [background-image] [background-repeat] [background-attachment]

[Background-position]/[background-size] [background-origin] [background-clip]; pay attention to the backslash in it.

Font is similar to the backslash used in the abbreviated form of border-radius. The backslash can be used in browsers that support this method in

Enter background-size after position. In addition, you can add another two attribute values: background-

Origin and background-clip. Its syntax is as follows:


   1: .example {   2: background: aquamarine url(img.png)   3: no-repeat   4: scroll   5: center center / 50%   6: content-box content-box;   7: }

4. the clip attribute of CSS takes effect only on absolutely positioned elements.

Add in style

   1: img   2:  {   3:     width: 200px;   4:     height: 200px;   5:     clip: rect(0px 50px 200px 0px)   6:  }

In HTML

1: 

No cropping found

Absolute positioning of img


   1: img   2:     {   3:         width: 200px;   4:         height: 200px;   5:         position: absolute;   6:         clip: rect(0px 50px 200px 0px)   7:     }

Valid clip values:


5. The percentage setting for the vertical element is relative to the container width, not the height.

When the width of an element is set by percentage, it is calculated relative to the width of the parent container. However, for some attributes that indicate vertical distance, such as padding-top, padding-bottom, margin-top, margin-bottom, etc. When you set them by percentage, it is based on the width of the parent container, not the height. Add a padding-top to the image:

 1: padding-top: 10%;

Based on the Effect and estimated distance, it can be proved that the calculation is based on the width.


6. The border-width attribute can use a predefined constant value.

In addition to standard width values (such as 5px or 1em), the border-width attribute can accept predefined constant values: medium, thin, and thick, if you do not assign a value to the border-width attribute, the default value is "medium ".


7. Do you know the empty-cells attribute in the table?

The empty-cells attribute in css is supported by all browsers, and even IE8 is used as follows:

 1: table { empty-cells: hide;}

It is estimated that you have guessed its role in semantics. It serves HTML table. It tells the browser to hide a table cell when there is nothing in it.

However, empty-cells is only used in the "split border" mode, that is, border-collapse: separate;


8. font-style's oblique Attribute Value

For the font-style attribute of css, I guess every time you see two attribute values: "normal" and "italic. But in fact, you can assign it "oblique ".


9. word-wrap and overflow-wrap are equivalent.

Word-wrap is not a common CSS attribute, but it is very useful in a specific environment. An example we often use is to display a long url with a line break instead of breaking the page. Add a sub-div to the original div and set the word-wrap attribute.

 

   1: <div style="width:250px;height:250px;border:1px solid red;word-wrap:break-word">   2:          My father was a self-taught mandolin player.   3:     He was one of the best string instrument players in our town.   4:     He could not read music, but if he heard a tune a few times,   5:     he could play it. When he was younger,   6:  </div>

Effect

Rather than cropping long words, the long words are displayed as an entire line. Replace word-wrap with overflow-wrap for the same effect.

However, note that the word-break attribute is used to crop long words.


   1: <div style="width:250px;height:250px;border:1px solid red;word-break:break-all">   2:          My father was a self-taught mandolin player.   3:     He was one of the best string instrument players in our town.   4:     He could not read music, but if he heard a tune a few times,   5:     he could play it. When he was younger,   6:     </div>

Effect

 

Appendix: word-wrap values:

Word-break value:

Original article: http://www.ido321.com/450.html












Does CSS learning require the knowledge of HTML?

Of course, HTML syntax is required for CSS knowledge ,,
You don't know the HTML syntax. How do you call CSS?

I am eager to find some tips, sayings, and habits about FOOD.

Canadian grain dates, Ganoderma lucidum increasingly grass.

Fine food tastes together, coarse grains gastrointestinal run.

Eat the carrots, are all diseases of Ukraine.

Fresh Prince a little more, do not have to herbal.

Three dog roll, waddled immortal.

Early morning cup of water, the old has no regrets.

Apple Daily even more difficult, do not have to go to the hospult.

Radish eat vegetables, Shabing no harm.

Garlic is a Po, eat the body good.

Tofu kelp distribution, in addition to eat disease.

A little more fresh ginger, do not have Preprocessor.

Chinese radish soup, healthy longevity.

Heat half-day Guatemala, the drugs do not have to grasp.

Gas less than a guilty conscience, longans cooked rice.

Salt in the morning to drink soup, win people to drink Ginseng.

I drink irritable heart, plus Kiwi porridge.

Sharp and spicy chili, by helping to digest food.

However Haocai food, wine, however the volume

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.