Summary-basic knowledge about CSS style sheets

Source: Internet
Author: User
[Conclusion]

I,UseCSSDisplay of style control page

  1. Intra-row style
    <P style = "color: red; font-size: 14px;">
  2. Embedded
    <Head>
    <Title> page title </title>
    <Style type = "text/CSS">
    Body {
    Margin: 0 auto;
    Width: 960px;
    }
    </Style>
    </Head>
  3. Link Type
    <Head>
    <Link href=”mycss.css "type =" text/CSS "rel =" stylesheet ">
    </Head>
  4. Import Style
    <Head>
    <Style type = "text/CSS">
    @ Import url(“mycss.css ");
    </Style>
    </Head>

II,CSSSelector

  1. Tag Selector
    For example, the Li selector is used to declare the style of all <li> tags on the page.
    <Style type = "text/CSS">
    Li {
    Color: red;
    Text-Decoration: none;
    }
    </Style>
  2. CATEGORY selector. Class
    . Error {color: red; font-size: 17px ;}
    Note: Another more intuitive way to use the class selector is to distinguish the class name directly after the label is declared.
    For example: h3.first _ class {color: Green}
  3. Id Selector
    The ID selector is basically the same as the class selector. The difference is that the ID selector can only be used once on the HTML page, so it is more targeted.
    For example: # Once {font-weight: bold; font-size: 30px ;}
  4. Collective declaration of selector, applicable to situations where the style of some selector is identical or partially identical.
    For example, H1, H2, H3, P {color: Purple; font-size: 14px ;}
    H2.special,. Special, # Once {text-Decoration: underline ;}
  5. Selector nesting. nesting can be used to declare HTML tags in special locations.
    For example, p B {color: yellow; font-size: 30px ;}
    It takes effect only for the B mark under the p Mark and does not take effect for the B mark outside the p Mark.
    Note: Typical nested statements
    1). Second I {color: black;}/* takes effect only for the <I> mark that uses the second class */
    2) # first Li {padding-left: 8px;}/* The <li> flag in the tag with ID first takes effect */
    3) UL Li {list-style: none ;}
    4) TD. Top, top1 strong {font-szie: 10px;}/* multiple nesting */
  6. Child selector, indicating to select a direct child element of the parent element, with the symbol ">"
    For example, ul. mylist> LI> A {text-Decoration: none ;}
    <Ul class = "mylist">
    <Li> <a href = "#"> link </a> </LI>/* only applies to this sentence because the sub-Selector */
    </Ul>
    <Li> <a href = "#"> link2 </a> </LI>/* This sentence does not work */
    If it is changed to Ul. mylist> Li a {...}, all <A> tags take effect.

Iii. Skills

  1. Common webpage width: 960px;
  2. Use Div to implement layout of one row and two columns
    <Div>
    <Div class = "Left"> first column </div>
    <Div class = "right"> second column </div>
    </Div>
    Note: 1) the sum of the width of the two columns cannot be greater than the width of the parent div;
    2) float: left/right for one of the columns;
  3. Use Div to implement layout of one row and three columns
    <Div>
    <Div class = "left_mid">
    <Div class = "Left"> first column </div>
    <Div class = "mid"> second column </div>
    </Div>
    <Div class = "right"> third column </div>
    </Div>
    Note: 1) the sum of the width of the three columns cannot be greater than the width of the parent Div;
    2) The float attribute of the control column.
  4. The default hyperlink style of the browser is: Blue + underline, and after clicking: Purple + underline.
  5. Differences between Div and span tags
    1) div is a block-level element, and all its elements are automatically wrapped;
    2) A span is an element in a row that does not wrap a line.
  6. About the margin and padding attributes
    1) if the attribute is connected and written, it is abbreviated as the top, right, bottom, and left order rule clockwise;
    2) When the attribute values are the same as those of the lower, left, and right, they can be abbreviated as: margin: 40px 50px;
    3) When both the top, bottom, and left attributes are consistent, the value can be abbreviated as: margin: 60px;
  7. Center the elements in the webpage
    Width: 960px;
    Margin: 0 auto;
  8. Div with float configured doubles the margin value in IE6, which is a bug in IE6.
    Solution: Add display: inline to the DIV style.
  9. Solve the vertical center problem of Div
    Vertial-align: Middle
    Line-Height: div 'height
  10. Difference between ID and class
    1) The ID cannot be repeated, and the class can be used repeatedly.
    2) The priority of ID is higher than that of class.
    3) ID saves time in some situations
  11. Set flash to transparent
    <Param name = "wmode" value = "Transparent">

I,UseCSSDisplay of style control page

  1. Intra-row style
    <P style = "color: red; font-size: 14px;">
  2. Embedded
    <Head>
    <Title> page title </title>
    <Style type = "text/CSS">
    Body {
    Margin: 0 auto;
    Width: 960px;
    }
    </Style>
    </Head>
  3. Link Type
    <Head>
    <Link href=”mycss.css "type =" text/CSS "rel =" stylesheet ">
    </Head>
  4. Import Style
    <Head>
    <Style type = "text/CSS">
    @ Import url(“mycss.css ");
    </Style>
    </Head>

II,CSSSelector

  1. Tag Selector
    For example, the Li selector is used to declare the style of all <li> tags on the page.
    <Style type = "text/CSS">
    Li {
    Color: red;
    Text-Decoration: none;
    }
    </Style>
  2. CATEGORY selector. Class
    . Error {color: red; font-size: 17px ;}
    Note: Another more intuitive way to use the class selector is to distinguish the class name directly after the label is declared.
    For example: h3.first _ class {color: Green}
  3. Id Selector
    The ID selector is basically the same as the class selector. The difference is that the ID selector can only be used once on the HTML page, so it is more targeted.
    For example: # Once {font-weight: bold; font-size: 30px ;}
  4. Collective declaration of selector, applicable to situations where the style of some selector is identical or partially identical.
    For example, H1, H2, H3, P {color: Purple; font-size: 14px ;}
    H2.special,. Special, # Once {text-Decoration: underline ;}
  5. Selector nesting. nesting can be used to declare HTML tags in special locations.
    For example, p B {color: yellow; font-size: 30px ;}
    It takes effect only for the B mark under the p Mark and does not take effect for the B mark outside the p Mark.
    Note: Typical nested statements
    1). Second I {color: black;}/* takes effect only for the <I> mark that uses the second class */
    2) # first Li {padding-left: 8px;}/* The <li> flag in the tag with ID first takes effect */
    3) UL Li {list-style: none ;}
    4) TD. Top, top1 strong {font-szie: 10px;}/* multiple nesting */
  6. Child selector, indicating to select a direct child element of the parent element, with the symbol ">"
    For example, ul. mylist> LI> A {text-Decoration: none ;}
    <Ul class = "mylist">
    <Li> <a href = "#"> link </a> </LI>/* only applies to this sentence because the sub-Selector */
    </Ul>
    <Li> <a href = "#"> link2 </a> </LI>/* This sentence does not work */
    If it is changed to Ul. mylist> Li a {...}, all <A> tags take effect.

Iii. Skills

  1. Common webpage width: 960px;
  2. Use Div to implement layout of one row and two columns
    <Div>
    <Div class = "Left"> first column </div>
    <Div class = "right"> second column </div>
    </Div>
    Note: 1) the sum of the width of the two columns cannot be greater than the width of the parent div;
    2) float: left/right for one of the columns;
  3. Use Div to implement layout of one row and three columns
    <Div>
    <Div class = "left_mid">
    <Div class = "Left"> first column </div>
    <Div class = "mid"> second column </div>
    </Div>
    <Div class = "right"> third column </div>
    </Div>
    Note: 1) the sum of the width of the three columns cannot be greater than the width of the parent Div;
    2) The float attribute of the control column.
  4. The default hyperlink style of the browser is: Blue + underline, and after clicking: Purple + underline.
  5. Differences between Div and span tags
    1) div is a block-level element, and all its elements are automatically wrapped;
    2) A span is an element in a row that does not wrap a line.
  6. About the margin and padding attributes
    1) if the attribute is connected and written, it is abbreviated as the top, right, bottom, and left order rule clockwise;
    2) When the attribute values are the same as those of the lower, left, and right, they can be abbreviated as: margin: 40px 50px;
    3) When both the top, bottom, and left attributes are consistent, the value can be abbreviated as: margin: 60px;
  7. Center the elements in the webpage
    Width: 960px;
    Margin: 0 auto;
  8. Div with float configured doubles the margin value in IE6, which is a bug in IE6.
    Solution: Add display: inline to the DIV style.
  9. Solve the vertical center problem of Div
    Vertial-align: Middle
    Line-Height: div 'height
  10. Difference between ID and class
    1) The ID cannot be repeated, and the class can be used repeatedly.
    2) The priority of ID is higher than that of class.
    3) ID saves time in some situations
  11. Set flash to transparent
    <Param name = "wmode" value = "Transparent">
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.