CSS style selector
Set the Style property on the label:
<body> <div style= "Background-color: #2459a2; height:48px;" > First floor </div> <div style= "Background-color: #2459a2; height:48px;" > Second floor </div> <div style= "Background-color: #2459a2; height:48px;" > Third Level </div></body>
Write the corresponding style directly in the DIV
ID Selector
Write the style into the head, named after the #, and call the corresponding style in the div with the id attribute to specify the corresponding ID name
Class selector (most commonly used)
Write the style to the head, named after the. Name, call the corresponding style in the Div.
Tag Selector
Tag Selector, set the div style, the contents of all div tags inside the body will be applied
Association selector (Hierarchy selector)
Apply styles only to the DIV tag within span, and can be nested in multiple layers
Combo Selector
Combo selector, plus, number, same style multiple naming
Property Selector
Filter matching based on attributes, only the first input tag matches the corresponding style
CSS Style referenceCSS style Precedence
If the styles do not conflict, the styles are applied, and if the style is conflicting, the style style has the highest precedence, followed by the order in which the other installations are written, the closer the priority
File Way Reference style
Define styles and save to commons.css file
. C1{background-color:red;color:white;}. C2{background-color:black;}
referencing commons.css files
<! DOCTYPE html>
CSS style borderBasic border
<body> <div style= "border:1px dotted red;" > First layer Border </div><!--border: Border width solid: Border Style solid line (dotted dashed) color:red--></body>
Border other styles
<body> <div style= "HEIGHT:48PX; width:80%; border:1px solid Brown; font-size:16px; Text-align:center; line-height:48px; " > Second Border </div> <!--height:48px Border height -<!--width:80% Width page 80%--> <!--border: 1px solid brown border width, style, color- <!--font-size:16px; Font Size- <!--text-align:center, horizontal center- <!--line-height:48px; vertically centered--></body>
-" Click to show Effect
CSS style floatingFirst knowledge of float
<body> <div style= "width:20%;background-color:red;float:left;" > Left </div> <div style= "width:80%;background-color:black;float:right;" > Right </div></body>
-" Click to show Effect
Float test Page
-" Click to show Effect
Note: <body style= "margin:0 auto;" > Remove the gap from the top of the browser;<div style= "Clear:both" ></div> child border floats, displays the border lines of the parent border
CSS style displayBlock-level labels and inline labels are converted to each other
<body> <div style= "Background-color:red;display:inline" > Block-level </div> <span style= " Background-color: #2459a2;d Isplay:block "> in-line </span></body>
-" Click to show Effect
Note: Display:inline is converted to inline labels, display:block to block-level labels, and Display:none not displayed
Inline Tags: Unable to set height, width, padding margin
Block-level Tags: set height, width, padding margin
<body> <span style= "Background-color: #2459a2;d isplay:inline-block;height:50px;width:70px" > inline </span> <div style= "Background-color:red;display:inline" > block-level </div></body>
-" Click to show Effect
Note: Display:inline-block has the properties of inline (the default number of its own) and the properties of the block (you can set the height, width, padding, margin)
CSS style marginMargins margin
<body> <div style= "border:2px solid red;height:70px;" > <div style= "background-color:green;height:50px; margin-top:25px; " ></div> </div></body>
-" Click to show Effect
Note: margin-top:25px represents the margin, and the distance between the child border and the parent border top is 25px
Internal margin padding
<body> <div style= "border:2px solid red;height:70px;" > <div style= "background-color:green;height:50px; padding-top:25px; " ></div> </div></body>
-"" Click Show Effects
Note: padding-top:25px represents the inner margin, and the distance between itself and top within the child border is 25px
Python development "frontend": CSS