1, CSS classification style is divided into 3 categories: inline, inline, external
(1) Inline: Written in the label, the style is style= ""
To illustrate:
<div style= "
width:100px;
height:110px;
background-color:red; " >
<p>
I'm the first line h
</p>
To run a sample diagram:
Style= "has a width of 100 pixels, a height of 110 pixels, and a green background." Set the CSS style for this div tag.
(2) Embedded: In
That
<style type= "Text/css" >
<style type= "Text/css" > </style>
Example:
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title></title>
<style type= "Text/css" >/* embedded inside body outside the head */
p{
color:red;
}/*P delegates Select all text */
. Lianxi
{
Color:yellow;
background:red;
height:100px;
width:100px;
}
</style>
<body>
<div class= "Lianxi" > I am Yangyang 1</div>
<div class= "Lianxi" > I am Yangyang 2</div>
<div class= "Lianxi" > I am Yangyang 3</div>
</body>
To run a sample diagram:
<body></body> inside there is a Class=lianxi point class that gives all classes equal to the practice of the background red, 100 pixels high, and a 100-pixel wide font in yellow.
(3) External, create a separate CSS file
<link rel= "stylesheet" type= "Text/css" href= "0809liaxi2.css"/>
To illustrate:
<meta charset= "UTF-8" >
<title></title>
<link rel= "stylesheet" type= "Text/css" href= "0809liaxi2.css"/>
Also in
2. Selector: class, ID, compound selection, attributes, Pseudo-class
(1) class, use point when selecting Class attribute. XX, filter elements according to the class name, and select the same duplicate name with the class attribute
Such as:
<div class= "Lianxi" > I am Yangyang 1</div>
<div class= "Lianxi" > I am Yangyang 2</div>
<div class= "Lianxi" > I am Yangyang 3</div>
Select Class Equals Lianxi is a point lianxi, so I am yangyang content is selected, and then you can give me is Yangyang content add attributes.
For example <style type= "Text/css" >
. (dot) Lianxi
{color:yellow;
}
</style>
(2) ID filter the unique element according to the ID name, cannot have the same name, with # plus the ID name
namely <div id= "Lianxi1" > I am Yangyang 1</div>
<div id= "Lianxi2" > I am Yangyang 2</div>
<div id= "Lianxi3" > I am Yangyang 3</div>
For example #lianxi1, this gives the attribute when it is given to me by Yangyang 1
(3) The comma table in the compound is parallel, the space represents the descendant, the greater than symbol represents all div>p, the P element in the Div.
Example: #yang, #yang2 {/* compound descendant */
BORDER:2PX Solid black/* Border is 2, border color is black */
}
div,p {
BORDER:2PX Solid Red
} All P-tags
(4) Four pseudo-classes of a tag: A:link not visited, A:visited visited label, A:active with selected label, A:hover Mouse is out of date
Example:
a:link{
Color:blue;
}<--when not accessed is blue---
a:visited{
Color:black;
} <--visited Black-and-
a:active{
Color:yellow;
}<---selected is yellow
a:hover{
Color: #FF0000;
}<--mouse over to show red--
:
4. Style: Background, font, alignment, border border, show hidden, list (unordered, ordered), format layout
(1) Background background \
Background-image:url (foot-bg.jpg); background image
Background-color background Color
Background-reapet picture Tiling method: background-size (background size): 100% 100%; fully expanded
Background-position background position
(2) Font
fonf-family font Style
Font-size Font Size
Font-style:italic Font Tilt
Font-wight Font Weight
Text-decoration: (1) Underline underline (2) overline dash (3) Line-through strikethrough (4) None Remove line
(3) Alignment
Text-align:center Horizontal Alignment
Line-height Line Height
Text-indent Indent Unit pixels
Line-height (Adjusts the vertical way of text, by setting the size of the row height) and vertical-align (adjusts the vertical alignment of the elements in the line)
(4) Border margin margins and padding padding (bored1px solid red for weight and color)
Margin on the right down to the left can only be adjusted around Margin-left and margin-right
Padding adds an inner margin element to be larger,
Examples of backgrounds, fonts, alignments, borders:
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title></title> <styletype= "Text/css">#name{Background-color:Red;/*background is red*/Height:90px;width:200px;Margin-left:60px;/*w outer margin border 60px*/Padding-top:90px;/*inner margin 90px above*/font-size:20px;/*Font Size*/Font-style:Initial;/*Tilt*/ /*text-decoration:underline; underline*/text-decoration:overline;/*Dash up*/Color:Yellow;/*Font Color*/Border:10px Solid:blue;float: Left}. Class{Background-color:Green;/*background is red*/Height:150px;width:400px; /*vertical-align:bottom;* Adjust the inline element vertical alignment of input, span, img/**/Line-height:140px;Margin-left:40px; } </style> </Head> <Body> <DivID= "Name">Infinite Ballad Season</Div> <Divclass= "Class">I want to sing with you</Div> </Body></HTML>
CSS Basic Knowledge collation