Home > Article > Web Front-end > CSS basics {property: value;}
1.CSS is the abbreviation of Cascading Style Sheets. It is used to define the display form of HTML elements.
2. There are three ways to introduce CSS into HTML:
a. External style sheet:
b. Embed style sheet:
c. Inline style sheet:
The attribute name is style. Example:
3. Selector in CSS:
A: Simple selector;
a: Element selector; Element { attribute: value; }
b: class selector; .class name { attribute: value; } Note that there is a dot.
c: ID selector; #id name { attribute: value; } Note that there is a #, the ID selector can only be referenced once, while the class selector can be referenced multiple times.
d: pseudo-class selector; (has four states) a:link 3. a:hover{ }( The mouse is on the link)
{ }
4. Compound selector :
a:Intersection selector: The intersection selector is composed of two selectors directly connected, and the result is to select the intersection of their respective element ranges.
The first one must be a tag selector, and the second one must be a category selector or ID selector. There can be no space between these two selectors.
b: Union selector:
c: Descendant selector: (inherited The influence of the nearest) descendant selector is not limited to the "direct descendants" of the element, but also affects its "descendants at all levels"
5. Understand the cascading of style sheets:
The priorities of the levels from small to large are:
External style sheet
use use using ’ s ’ s
use using ’s ’ through ’s ‐ through ‐ ‐‐ ‐‐ ‐ ; Basic attributes---Text style
1. Length unit 1.px 2.em
2. Color definition color
3. Set font style Set the font of the text font-family: "Heilong";
Set the font tilt effect font-style :Italic;
using font-weight: 100 (range 100-900, the larger the font) The thicker)
Set English letter case conversion text-transform: capitalize; (capitalize the first letter of a word)
Set control text size font-size:..px/..%/..em
out through ’ s through through use through ’ through ’ through ’ s ‐ ‐ off ‐‐ ‐‐‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ ‐ underline/line-through (strikethrough)/overline (top line);
4. Set the paragraph style Set the indent of the first line of the paragraph text-indent: ..em (..standard character size distance)/..px ;
‐ ‐ ‐ ‐ ‐ ‐ ‐ set the distance between words letter-spacing (letters):..px; . Controlling the horizontal position of text text-align :left/right (right-aligned)/center (centered)/justify (aligned at both ends)
Set the text and background color background-color:...; :...;(Only works for elements in table cells)
Basic attributes of css - image style
1. Set the picture border: border-width: (thickness) ; border-color: (color) ; border-style: (linear) ;
Different borders can be set in different styles. eg: border-left-style, border-top-width .... solid solid line
2. Image scaling: width height (percent, pixels)
3. Mixed graphics and text:
Text wrapping: float (floating)
Alignment of pictures and text: horizontal alignment text-align:
<br/>
Vertical alignment vertical-align: : Indicates the header of the table : Indicates the content of the table : Indicates the tail of the table (The order can be different, but it is generally in order) and unordered list Attribute rotate(angle) Effect: When the mouse moves up, the list can rotate to the angle you set. (Zheng is clockwise, negative as counterclockwise, if it is 180 degrees, you can see that the word is inverted. You cannot clearly see the rotation , but you can see the change of the word) transform (conversion): rotate (rotate; cycle to rotate; make rotation; make turns) (-20deg) ; deg: degree (degree) 1. The concept of box: In CSS, an independent box model has 4 content (content), border (border), padding (inner margin) and margin (outer margin) Partially composed. 3-- to 3. the relationship between boxes:
4,. Set the background color and image: background-color: background-image:url(address) You can use background-repeat: to control tiling, repeat: horizontal and vertical tiling, default value. At No-Repeat: Not flat. X Repeat-X: Laip it in the horizontal direction.
.
5. Set the background image position: background-position: (two values can be set eg: left top)
6. Set the background image fixed position: background-attchment: fixed; Image scrolling: scroll
small dots, list-style: none; Positioning (see position7) 1. Absolute positioning: (The element frame set to relative positioning will be offset by a certain distance. The element still retains its shape before positioning, and the space it originally occupied is still retained. )
The position of the element is relative to the nearest positioned element,
Top:..px;
px;
. : table border bgcolor: table color border-collapse: merge adjacent columns Border line
border-spacing using using using using through through out through through out through out through through off ‐ ‐ ‐ ‐‐ ‐‐‐‐border
2. Set the style of the table when the mouse passes over: a:hover
3. CSS and form: a: production Button like text
transparent (transparent) Set the background to be transparent
border:0px; eg:
b: Make a colorful drop-down menu select option
c: Make an input box with only underline border: 0px/none;
border- bottom: 1px (thickness) dashed (linear) #000000 (color);
Supplement: 1. display: block (row-level elements are replaced with block-level elements) / inline (block-level elements are replaced with row-level elements)
Device:: NTH-OF-TYPE (N) Selector matching each element of the n n element of the nly element of the parent element .
N can be numbers, keywords or formulas.
Use CSS to set links and navigation menus (les9)
1. Set hyperlink styles: In HTML a:visited (visited). a:link{ } a:active{ }
(You can set these) background: ;
color: ; Border-top: px .
3. Make a fluorescent menu: Apply an unordered list,
, a:hover, (check les9).
4. Control the mouse (cursor) pointer . {cursor: } (check other CSS 2.0 Chinese manuals under properties).
5. Set the project list format: You can use ordered list
and
absolute: Absolute positioning (The relative position of the parent element will affect the box behind him as if the box is taken away, and other boxes in the back will fill fixed: fixed positioning (when the scroll bar slides, it will not change its position, it will always be there.)
2. Positioning of the box (static):
will maintain the original high and low coverage relationship.)
4. Inline has two values, one represents block-level display and the other represents inline display. display also has a value of none. When set to none, it means that the element will be hidden. This hiding means that the element completely disappears from the page. . 8.28o1.overflow (overflow): There are four values: visible (default value. No cut content or increase the scroll bar)
inline-block: Inline block element.