"Front-end notes"? Css

Source: Internet
Author: User

1.What is CSS
    • The full name of CSS is cascading style Sheets, cascading style sheets. It is used to control the style of HTML tags, in the beautification of the Web page plays a very important role.

CSS is written in the form of key-value pairs, such as

color:red;

Background-color:blue;

font-size:20px;

The left side of the colon is the property name, and the right side of the colon is the property value.

CSS follows a rule: the nearest principle (multiple definitions of the same style, whichever is closest to the content ), and the overlay principle (the same style only appears once defined, whichever occurs)

2. CSS has 3 forms of writing

  1 inlinestyle: (inline style) write directly in the label's style property

<body style= "color:red;" >

2"in-page style: write in the style tab of this page

<style>

Body {

color:red;

}

</style>

3external style: write in a separate CSS file and then refer to it in the Web page with the link tag

    relation relationship, to tell the browser what to import. (cascading style sheets)

<link rel= "stylesheet" href= "Index.css" >

3. Two main points of CSS

Properties: A complex overlay of attributes to make a beautiful web page

The role of the selector: find the corresponding label setting style by selector (selector is used to find the label in the page, to set the style)

1 "Tag Selector    /*1. Tag Selector*/Div{Color:Red; }P{Color:Blue; }<div>11111</div> <p>222222</p>
2 format of class selector /*2. Class selector*/. One{Color:Yellow; }<div class= "One" >3333333</div> <p class= "one" >444444</p>
3 The format of the ID selector /*3.id Selector*/#first{font-size:40px; }<div id= "First" >555555</div> <!--ID selector can only be used once, is uniquely identified, cannot be reused anywhere else-<!--<div Id= "First" >666666</div>-->
4 "Parallel selector /*Parallel Selector*/Div,.one{Color:Blue; Description: A parallel selector is a combination of styles that combine multiple labels with the same style.
5 "Composite selector /*Composite Selector*/Div. One{Background-color:Lightgray; }#first Div{Color:#84ffdb; Description: Composite selector is a way to reduce the positioning of the range, easy to quickly locate. (First look for the div tag, then the DIV tag to find the class selector that sets the one.) )
6 "direct descendant selector /*Direct descendant Selector*/div > P{Color:Red; Description: Locate the P tag inside the Div, including all the Son-level P tags, excluding the sun-level p tag.
7 "adjacent brother selector /*adjacent Sibling selector*/Div + P{Color:Red; Description: Locates a nearest p tag that is parallel to the Div.
8 "attribute selector /*Property selector, locating the div with the name attribute*/Div[name]{Color:Red; }/*Property Selector, positioning the Name property value to Zhangsan div*/div[name= "Zhangsan"]{Color:Blue; }/*Property selector, locating the div with the name attribute and the Age property*/Div[name][age]{Color:Gray; } <!--Div has a Name property --<div name= "Zhangsan" >11111</div> <div name= "Lisi" >22222 </div> <!--div has two properties: Name and age--> <div name= "Wangwu" age= "All" >333333</div>
9 "pseudo-classAfter the selector, add ": Attribute", when this property is triggered, you can change the selector corresponding to the style of the label. Tags: property {style}  
Div{Background-color:Red;width:300px;Height:300px; }/*pseudo-Class: Change the style of the div when the mouse is placed on the Div area (WebView not supported, click to see the effect)*/Div:hover{Background-color:Green;width:100px;Height:100px; }/*pseudo-Class: Changes the style of input border when the input box gets focus (in edit state)*/Input:focus{/*Remove the blue from the outer frame*/Outline:None;/*border: is a composite property. (1. Border width 2. Border Style: Solid solid, dashed line dashed, double ring 3. Border color)*/Border:1px solid Yellow; }

  

"Front-end notes"? Css

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.