web123456

An article that takes you through CSS basics in detail

catalogs

I. CSS Style Sheets

Second, CSS style rules

1. Selector

Second, the introduction of CSS style sheets

1. Introduce CSS in-line

2. Inline introduction of CSS styles

3. Chained introduction of CSS

Third, the basic CSS selector

1. Marker selector

2. Class Selector

picker

4. Wildcard selector

Fourth, CSS text appearance properties

(1) Predefined colors:

(2) Use of hexadecimal definitions

(3) RGB code

-spacing

-spacing

-height

-align

-transform

-decoration

Example:

Realize the effect:

-indent

-space

V. CSS list markup

1. Unordered list

Attention:

Example:

Realization of results:

2. Ordered lists

Example:

Realization of results:

3. Define the list

Example:

Realize the effect:

4. Application of list nesting

Example:

Six, CSS font settings

-size

-famiy

-weight

compiler

-variant

-style

Seven, with CSS control list style

1. Example code

Realize the effect:

VIII. Hyperlinks

1. Grammar

2. Examples

Realization effects

3. Anchor connection

4. Connecting pseudo-classes to control hyperlinks

5. Hyperlink pseudo-classes

Attention:

IX. Tables and forms

1. Creating Forms

(1

(2)

(3)

Tag Attributes

(1)border

(2)cellspacing

(3)cellpadding

Results.

Tag Attributes

(1)height

(2)align

(3)bgcolor

(4)background

(5)valig

  (6)bgcolor

Tag Attributes

tab (of a window) (computing)

X. Forms

1. Role

2. Composition

(1) Reminder

(2) Form fields

(3) Form Controls

3. Creating Forms

(1)action

(2)method

(3) GET request

(4) POST request

(5)name

a control (e.g. button, text box etc) (computing)

(1) Single-line text input boxes, radio buttons, check boxes, buttons, etc.

Single line text input box

password box

(2) Single choice

(3) Multi-select box

(4) Buttons

(5) Picture button

(6) File upload button

(7)value 

a control (e.g. button, text box etc) (computing)

a control (e.g. button, text box etc) (computing)

Attributes of the select and option tags

7. Grouping

basic grammatical format

XI, CSS control form style

Control background color and image in

(1) Setting the outer margin

(2) Setting the inner margin

(3) Setting the mouse


I. CSS Style Sheets

existhtml pageIt can make the page beautiful, generous, and easy to upgrade, easy to maintain, and also realize the separation of structure and display.

Second, CSS style rules

1. Selector

for specifyingCSS styleThe HTML object that is used, with the display style for that object in parentheses.

Selector {attribute1: attribute value 1; attribute2: attribute value 2; attribute3: attribute value 3 ...... attribute n: attribute value n}

Attribute values and attribute values between the use of "key-value pairs" way to appear, with the English ". ", and ";" is used to distinguish between multiple keys.

Advantages: the use of flexible, you can do the same tag different settings CSS style

Cons: Can't standardize formatting within the same tab.

colorSet the display color

font-size: set the display font size

text-align: set text alignment

intitle: search content, you can precisely match the search content

In CSS, /* */ is used to comment out content

Second, the introduction of CSS style sheets

1. Introduce CSS in-line

Inline style, also commonly referred to as inline style, is the syntactic formatting that sets the style of an element through the style attribute of a tag:

  1. <Tag name style="Attribute 1: attribute 1: attribute value 1; attribute 2: attribute value 2; ...... Attribute n: attribute value n">
  2. element
  3. </label name>

Advantages: the use of flexible, you can pass yo a label to do different settings CSS style

Cons: Can't standardize formatting within the same tab

2. Inline introduction of CSS styles

Write the CSS code centrally in the HTML document, this CSS style code is in the <head> head tag and is formatted using the <style> syntax:

  1. <head>
  2. <style type="text/css">
  3. Selector {attribute1: attribute value 1; attribute2: attribute value 2; attribute3: attribute value 3 ...... attribute n: attribute value n}
  4. </style>
  5. </head>

3. Chained introduction of CSS

Chaining is to put all the styles in one or more external style sheet files with a .css extension, and introduce them into the HTML document through the <link> file, the basic syntax format:

  1. <head>
  2. <link rel="stylesheet" type="text/css" href="css file path">
  3. </head>

If the CSS file and the HTML document are not on the same disk, use fil:/// absolute paths.

Third, the basic CSS selector

1. Marker selector

It refers to the use of HTML tags as selectors, categorized by tag name, to specify a uniform CSS style for a certain class of tags on the page.

Tag name {attribute 1: attribute value 1; attribute 2: attribute value 2; .... ; attribute n: attribute value n}

2. Class Selector

Use the English symbol ". ", followed by the class name, the basic syntax format:

. Class name {attribute 1: attribute value 1; attribute 2: attribute value 2; .... ; attribute n: attribute value n}

CSS for adding a range attribute to one of the tags

Tag Name. Class name {attribute 1: attribute value 1; attribute 2: attribute value 2; .... ; attribute n: attribute value n}

CSS for adding a range attribute to a class

. Class name 1. Class name 2 {attribute 1: attribute value 1; attribute 2: attribute value 2; .... ; attribute n: attribute value n}

Valid only if class 2 is introduced to the extent that class 1 was introduced first

picker

The id selector is usually denoted by # followed immediately by the id name in its basic syntax format:

id name {attribute 1: attribute value 1; attribute 2: attribute value 2; .... ; attribute n: attribute value n}

CSS scope control can be achieved in the following ways

  1. #id name #id name 02{attribute 1: attribute value 1; attribute 2: attribute value 2; .... ; attribute n: attribute value n}
  2. #id name . Class name {attribute 1: attribute value 1; attribute 2: attribute value 2; .... ; attribute n: attribute value n}

4. Wildcard selector

Usually use * to represent, it is the scope of the entire HTML page in all the elements, the basic syntax format

*{attribute 1: attribute value 1; attribute 2: attribute value 2; .... ; attribute n: attribute value n}

Fourth, CSS text appearance properties

This attribute is used to define the text color, which can be taken in three ways:

(1) Predefined colors:

red, yellow, blue, etc.

(2) Use of hexadecimal definitions

#FFF6600, which is commonly used in practice, is thehexadecimal

(3) RGB code

Red: rgb(255,0,0)

-spacing

Used to define the word spacing, that is, the space between the character and the character, the value of its attributes can be different units of value, allowed to be negative, the default is NORMAL, a positive number is to increase the arduous, negative is to reduce the spacing.

-spacing

Used to define the spacing between English words, not valid for Chinese characters, the value is the same as the letter-spacing above.

  1. .p1{
  2. color:red;
  3. letter-spacing: 70px;
  4. }
  5. .p2{
  6. color: blue;
  7. word-spacing: 70px;
  8. }

-height

Used to set the line spacing, the value of its attribute has three units, respectively, px, em, %

-align

Sets the horizontal alignment of the text content, equivalent to the align attribute in html.

left

right

center

-transform

You can control the case of English characters with the following attribute values:

none: no conversion

capitalize: initial capitalization

uppercase: convert all characters to uppercase

lowercase: all characters converted to lowercase

-decoration

Controls the underlining of text with the following property values:

none: no decoration, default value

underline

overline.

line-through: strikethrough

Example:

  1. <html>
  2. .p3{
  3. line-height: 25px;
  4. text-align: center;
  5. color:blue;
  6. font-size: 15px;
  7. letter-spacing: 25px;
  8. }
  9. .p4{
  10. text-align: center; /* centered */
  11. text-transform:capitalize ; /* initial capitalization */
  12. text-decoration: underline; /*underline*/
  13. }
  14. .p5{
  15. text-align: right; /* right-aligned */
  16. text-transform:uppercase ; /*Letter capitalization**/
  17. text-decoration: overline; /*upline*/
  18. }
  19. .p6{
  20. text-align: right; /* right-aligned */
  21. text-transform:uppercase ; /*Letter capitalization**/
  22. text-decoration: line-through; /*strikethrough*/
  23. }
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <p class="p4">hello world</p>
  29. <p class="p5">hello world</p>
  30. <p class="p6">hello world</p>
  31. </body>
  32. </html>

Realize the effect:

-indent

Used to set the first line of text indentation, its value attribute can be em, px, etc..

-space

Used to handle whitespace characters, there are three attributes

normal: default value, invalid for spaces and blank lines in the text, automatic line feed after a full line.

pre: pre-formatting, according to the writing format of the document to retain spaces, blank lines, display as is

nowrap: space, blank line is invalid, forced text can not be line feed, unless encountered label <br>, otherwise the content beyond the boundary does not line feed, if beyond the boundary will automatically increase.

V. CSS list markup

In order to allow users to read easily, so the web page information in the form of a list of displays, HTML provides three commonly used lists, respectively, unordered lists, ordered lists, the definition of lists

1. Unordered list

Unordered lists are commonly used in web pages, the reason why it is called an unordered list, because, in the list of each list item for the relationship between the side-by-side, the basic syntax of the format

  1. <ul>
  2. <li>List item 1</li>
  3. </ul>

Attention:

1. The use of the type attribute of a whiskerless list is frowned upon, and is generally replaced by CSS styling.

2.<li></li> between the equivalent of a container that can hold all the elements, but <ul></ul> can only be nested between <li></li>, directly in the <ul></ul> in the text, is not allowed.

Example:

  1. <body>
  2. <h2>Unordered List Test</h2>
  3. <ul>
  4. <li>List item 1</li>
  5. <li>List item 2</li>
  6. <li>List item 3</li>
  7. </ul>
  8. </body>

Realization of results:

2. Ordered lists

An ordered list sorts the list items in a certain order, the basic syntax format is

  1. <ol>
  2. <li>list item</li>
  3. </ol>

Example:

  1. <ol>
  2. <li>
  3. List item 1
  4. </li>
  5. <li>
  6. List item 2
  7. </li>
  8. <li>
  9. List item 3
  10. </li>
  11. </ol>

Realization of results:

3. Define the list

Usually use <dl> tags, often used for the even of terms, or the description of the noun, the definition of the list of list items do not have any bulleted, basic syntax format:

  1. <dl>
  2. <dt>Noun 1</dt>
  3. <dd>Noun Explanation 1</dd>
  4. <dd>Noun Explanation 2</dd>
  5. .....
  6. <dt>Noun 2</dt>
  7. <dd>Term 2 Explanation 1</dd>
  8. <dd>Term 2 Explanation 2</dd>
  9. </dl>

In web design, definition lists are often used to achieve the effect of mixed text and graphics

Example:

Realize the effect:

4. Application of list nesting

If you want to define sub-list items within a list item, you need to nest the list.

Example:

Realization of results:

Six, CSS font settings

-size

Used to set the font size of the font, this property can be used in relative length units or absolute length units.

-famiy

Used to set fonts, common fonts in the web page, there are Song, bold, Microsoft Yahei and so on.

-weight

Used to set the thickness of the font

-variant

Setting font variants, generally used to define upper and lower case letters

normal: default value

small-caps: converts all lowercase letters to uppercase

-style

Used to set the style of the font, e.g. set italics, etc.

normal: default value

italic:italicized

oblique: agreement

Seven, with CSS control list style

1. Example code

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style type="text/css">
  5. li{
  6. list-style: none ; /* Clear default list style */
  7. background: url(images/) no-repeat ; /* Introduce images for list */
  8. padding-left: 26px; /* Set left margin */
  9. line-height: 26px; /* Setting line spacing */
  10. color: red; /* Font color */
  11. background-color: white; /* Background color */
  12. }
  13. </style>
  14. <title>
  15. </title>
  16. </head>
  17. <body>
  18. <h2> Transnational Teaching Material</h2>
  19. <u1>
  20. <li>Photoshop CS6 image design case tutorial</li>
  21. <li>Web Design and Production (HTML+CSS)</li>
  22. <li>PHP Web Development Tutorials</li>
  23. <li>C Development Tutorials for Beginners</li>
  24. </u1>
  25. </body>
  26. </html>

Realize the effect:

VIII. Hyperlinks

1. Grammar

Can help web sites to realize, from a page to other pages.

To create a hyperlink in HTML, simply <a></a>

  1. <a href="Jump targets" target="Pop-up mode of the target window">
  2. Text or Image
  3. </a>

The value of target: _self means open in the original window, _blank means open in a new window.

2. Examples

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title></title>
  7. </head>
  8. <body>
  9. <! -- Text hyperlinks -- >!
  10. <a href="" target="_self">Baidu's website</a>
  11. <! -- image hyperlinks -->
  12. <a href="hyperlink.html" target="_blank">
  13. <img src="C:\Users\DD\Desktop\">
  14. </a>
  15. </body>
  16. </html>

 Realization effects

3. Anchor connection

When browsing the web, to increase the speed of information retrieval, anchor links can be created to allow users to quickly locate the target content

  1. <a href="#id name">
  2. link text
  3. </a>

In the anchor, use the id name to

Create tag id names, just use the id attribute in the tag

<label name> random access memory (RAM)</label name>

4. Connecting pseudo-classes to control hyperlinks

In CSS, through the connection pseudo-classes, you can realize different connection states, is the hyperlink before clicking, after clicking, and when the mouse is hovering in different styles, hyperlink pseudo-classes have the following four kinds of

5. Hyperlink pseudo-classes

a:link{CSS style rule;} hyperlink status when not visited

a:visited{CSS style rule;} Connection status after visit

a:hover{CSS style rule;} mouse over hover state

Attention:

If you use 4 pseudo-classes at the same time, it will probably not work

Pseudo-classes can not only control the text style, but also set the hyperlink background, border and other styles

IX. Tables and forms

Tables are used in web pages not only for aligning data, but also for web page layout.

1. Creating Forms

Creating a table requires the use of 3 tags:

(1)<table></table>

Define a table

(2)<tr></tr>

Define a row in a table, nested in <table></table>

(3)<td></td>

Define cells in a table, nested in <tr> </tr>

Tag Attributes

(1)border

Set the border of the form (default border="0" no border)

pixel value

(2)cellspacing

Set blank margins between cells and cell borders

Pixel value, default is 2

(3)cellpadding

Setting the space between the cell content and the border

  1. <body>
  2. <table border="1" cellspacing="8" cellpadding="4"> <! -- Define the table -->.
  3. <tr> <! --Define the first row in the table -->!
  4. <td>1-1</td>
  5. <td>1-2</td>
  6. </tr>
  7. <tr> <! --Define the second row in the table -->!
  8. <td>2-1</td>
  9. <td>2-2</td>
  10. </tr>
  11. </table>
  12. </body>

Results.

Tag Attributes

(1)height

Setting the row height

pixel value

(2)align

Setting Horizontal Alignment

letf center right

(3)bgcolor

Setting the rowsbackground color

Predefined color values, hexadecimal, rbg

(4)background

Setting the row background image

url address

(5)valig

Set the vertical alignment of this line

top,middle,bottom

  (6)bgcolor

Setting the row background color

Predefined color value, hexadecimal, rgb

Tag Attributes

tab (of a window) (computing)

The th tag is usually used to set the header of the table, and its text is bolded and centered by default.

X. Forms

1. Role

It can be used to collect user information, or it can be used as a vehicle to submit information to the server through a form.

2. Composition

Tips, Form Fields, Form Controls

(1) Reminder

Mainly descriptive text that prompts the user on how to fill out and operate the program

(2) Form fields

Equivalent to a container for all form controls and prompts

(3) Form Controls

is the core of a form , contains specific form functional items , such as : single-line text input box , password box , check boxes , submit buttons and so on.

3. Creating Forms

To allow the data in the form to be submitted to the back-end server, it is necessary to define the form field, using <form></form> tags in HTML to define the form field, the basic format:

  1. <form action="URL address" method="Mode of data submission" name="Form name">
  2. Various controls
  3. </form>

(1)action

Used to specify the URL address of the server that receives and processes the form data.

(2)method

The user sets the submission method of the form data, which takes the value of GET or POST.

(3) GET request

Data is displayed in the browser's URL address, confidentiality is poor, and the amount of data is limited.

(4) POST request

Does not limit the data to the URL address, hides the data, better confidentiality, no limit on the amount of data

(5)name

Used to specify the name of a form to distinguish between multiple forms on the same page.

a control (e.g. button, text box etc) (computing)

(1) Single-line text input boxes, radio buttons, check boxes, buttons, etc.

<input type="control-price-type">

causality

attribute value

corresponds English -ity, -ism, -ization

type

   text

Single line text input box

 password

Password input box

radio

radio button

checkbox

checkbox

button

normal button

submit

Submit button

reset

Reset button

image

Picture Buttons

hidden

hidden field (computing)

name

User-defined

Define the name of the space

value

User-defined

Default text value for the input space

size

positive integer

The width of the input space to display on the page

disabled

disabled

Disable the control on first page load

maxlength

positive integer

Controls the maximum number of characters allowed to be entered

checked

checked

Defining controls to be selected by default

Controls can still be inserted in <p></p> labels, or <br> labels can be

Single line text input box

password box 

(2) Single choice

First radio-sex, only radio buttons can be selected

The second radio <lable> can expand the selection of controls

 

Although the effect is the same, clicking on the font still allows you to select the

(3) Multi-select box

(4) Buttons 

 

(5) Picture button 

 

(6) File upload button 

(7)value 

 

a control (e.g. button, text box etc) (computing)

Can create multi-line text input boxes, basic syntax formatting, commonly used in message boards

  1. <textarea cols="Number of characters per line" rows="Number of lines displayed">
  2. text box
  3. </textarea>

The two properties, rows and cols, may be understood differently and therefore displayed differently, which can be controlled in practice using CSS. The width and height of multi-line text.

a control (e.g. button, text box etc) (computing)

Drop-down menus can be defined. Basic syntax formatting

  1. <select>
  2. <option>Option 1</option>
  3. <option>Option 2</option>
  4. <option>Option 3</option>
  5. 。。。。。。。。。
  6. </select>

 

Attributes of the select and option tags

tab (of a window) (computing)

Common Properties

descriptive

select

size

Specifies the number of visible options for the drop-down menu (takes a positive integer)

multiple

Define the multiple="multiple" dropdown menu to realize the multi-option function.

option

selected

Define that when selected="selected", the current option is selected by default.

 

7. Grouping

basic grammatical format

  1. <select>
  2. <optgroup lable="Group name 1">
  3. <option>(cooked) rice</option>
  4. <option>sammy</option>
  5. <option>steamed stuffed bun</option>
  6. <option selected="selected">steamed bread</option>
  7. </optgroup>
  8. <optgroup lable="Group name 2">
  9. <option>(cooked) rice</option>
  10. <option>sammy</option>
  11. <option>steamed stuffed bun</option>
  12. <option selected="selected">steamed bread</option>
  13. </optgroup>
  14. ..............
  15. </select>

XI, CSS control form style

Use CSS to control form fonts, borders, backgrounds, inner and outer margins, etc.

Control background color and image in

background: url (path) no-repeat

Special usage: set transparent background color, background:rgb(255,255,0,0,5) white 50% transparency

(1) Setting the outer margin

margin: top, right, bottom, left, in common px units

(2) Setting the inner margin

margin: top, right, bottom, left. Commonly used units are px

(3) Setting the mouse

cursor: pointer; hand mouse