Detailed explanation of CSS style sheets and format layout

Detailed explanation of CSS style sheets and format layout

Style Sheets

CSS (Cascading Style Sheets) is used to beautify HTML web pages.

Inline style sheet: Example: <p style="font-size:10px;">Inline style sheet<p>

Inline style sheet: must be written in the head tag

Example: <style type="text/css">

p

{ style;}

</style>hei

External style sheet: Create a new CSS file to place the style sheet. Right-click in HTML--CSS style--Attach style sheet

Example: <style type="text/css">

*

{ margin:0px; padding:0px;} //The webpage margin is 0 pixels and the font spacing is 0 pixels

.mian //class selector <div class="mian"></div>// Call class style sheet

{

height:40px;

width:100px;

text-align:center;

background-color:red;

}

#mian//ID selector <div id="mian"></div> //Call ID selector

{

height:40px;

width:100px;

text-align:center;

background-color:red;

}

</style>

Compound selector: (1) P, span, used to separate two tags with the same style.

(2) Mian P separated by a space indicates descendants

(3) mian.p is separated by "." to indicate the p tag in the mian tag

In the style attribute, for example: margin: 20px 0px 20px 0px means the width of the border is 20 pixels on the top, 0 pixels on the right, 20 pixels on the bottom, and 0 pixels on the left. The order is clockwise: top-right-bottom-left.

Format layout

Lock position (position relative to the browser, i.e. the position relative to the browser remains unchanged no matter how the browser scrolls) position:fixed;

Absolute and relative positioning (1) If the outer layer does not have absolute (or relative), then the div is positioned relative to the browser

(2) If the outer layer has absolute(relative), then the div is positioned relative to the outer border using position:absolut; (absolute position) position:rel; (relative position)

Layering: If you want a label on the page to always be displayed on the top, you need to set the z value, such as: z-index:2; //If the z value is 2, it will be displayed on the upper layer. If it is not changed, the default value is 1, and they are all on the same layer.

The order of common hyperlink style definitions is L --v--h--a

a:link The state of a hyperlink before it is clicked

a:visited The state after a hyperlink is clicked

a:hover When the mouse hovers over a hyperlink

a:active When clicking a hyperlink

The above is all the content of the detailed explanation of CSS style sheets and format layout brought to you by the editor. I hope you will support 123WORDPRESS.COM~

Original URL: http://www.cnblogs.com/ouyangtangfeng99/p/5377983.html

<<:  CSS3 realizes the red envelope shaking effect

>>:  Summary of commonly used escape characters in HTML

Recommend

Detailed explanation of docker's high availability configuration

Docker Compose Docker Compose divides the managed...

Detailed explanation of mysql replication tool based on python

Table of contents 1. Introduction Second practice...

IDEA2021 tomcat10 servlet newer version pitfalls

Because the version I used when I was learning wa...

Two ways to build a private GitLab using Docker

The first method: docker installation 1. Pull the...

Springboot+Vue-Cropper realizes the effect of avatar cutting and uploading

Use the Vue-Cropper component to upload avatars. ...

Example code for implementing background transparency and opaque text with CSS3

Recently, I encountered a requirement to display ...

Advanced explanation of javascript functions

Table of contents Function definition method Func...

JavaScript BOM location object + navigator object + history object

Table of contents 1. Location Object 1. URL 2. Pr...

Detailed explanation of XML syntax

1. Documentation Rules 1. Case sensitive. 2. The a...

JavaScript implements long image scrolling effect

This article shares the specific code of JavaScri...

Example code for converting html table data to Json format

The javascript function for converting <table&g...

How to install the graphical interface in Linux

1. Linux installation (root user operation) 1. In...

Tutorial on installing and configuring MySql5.7 in Alibaba Cloud ECS centos6.8

The default MySQL version under the Alibaba Cloud...

Analysis of the advantages and disadvantages of MySQL stored procedures

MySQL version 5.0 began to support stored procedu...

How to add shortcut commands in Xshell

As a useful terminal emulator, Xshell is often us...