国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Web Front-end H5 Tutorial Xiaoqiang's road to HTML5 mobile development (4) - CSS2 and CSS3

Xiaoqiang's road to HTML5 mobile development (4) - CSS2 and CSS3

Jan 22, 2017 am 10:34 AM

In the previous article, we mentioned that learning HTML5 requires knowledge of CSS. When designing the page, you need to know the layout and structure of the Html5 page. To achieve a very gorgeous and beautiful interface, you need to use CSS. Let's first review the basic usage of CSS2, and then look at the relationship and difference with CSS3.

1. What is css?

Cascading stylesheet (cascading stylesheet) provides expression form for web pages. According to W3C specifications, when designing a web page, the data and structure of the web page should be written in the html file, the appearance of the web page should be written in the css file, and the behavior of the web page should be written in the .js file. The purpose of this is to separate the data, appearance, and behavior of the web page to facilitate code maintenance.

2. CSS selector:

(1) Tag selector (simple selector)

(2) Class selector

.s1{  
    屬性名:屬性  
}

There is also a class selector with a name, as follows:

 div.s1{  
    font-size;120px;  
}

(3) id selector

#d1{  
    font-size:italic;  
    font-weight:900;  
}

(4) Selector grouping

h1,h2,h3{   //用逗號(hào)隔開(kāi)  
<span style="white-space:pre">  </span>color:bllue;  
    }

(5) Selection Derived

#d2 p{  
span style="white-space:pre">   </span>color:red;  
font-size:300;  
    }

Comments in CSS

/*   */

Priority of style:


External style, write the style in .css
Internal style in the file, write the style in the .html file
Inline style, write the style inside style=" "
When a conflict occurs: external style

Two key attributes in CSS:

(1) display attribute


has three values:
block by block Display the mark as a mark
inline Display the mark as an inline mark

none Do not display

<html>  
    <!--display屬性-->  
    <head>  
        <style>  
            #d1{  
                width:200px;  
                height:100px;  
                background-color:red;  
                color:white;  
                font-size:40px;  
                display:inline; <!--改為行內(nèi)標(biāo)記-->  
            }  
            #d2{  
                width:200px;  
                height:100px;  
                background-color:blue;  
                color:white;  
                font-size:40px;  
                display:inline; <!--改為行內(nèi)標(biāo)記-->  
            }  
        </style>  
    </head>  
    <body>  
        <div id="d1">hello1</div>  
    <!--標(biāo)記d2會(huì)另起一行顯示-->  
        <div id="d2">hello2</div>  
    </body>  
</html>

(2) The position attribute
has three values:
static:Default value. The browser will place the tags in the default way (left-right, top-bottom).
Absolute: Offset relative to the parent mark (the mark where it is located).
relative: First place it in the default way, and then offset it.


Commonly used attributes are as follows:

 (1)文本相關(guān)的屬性  
font-size:30px; //字體大小  
font-style:normal(正常)/italic(斜體)  
font-weight:800; //100-900 (粗細(xì))  
font-family:"宋體"; //字體  
text-align:left/center/right;  //文本水平對(duì)齊方式  
line-height:30px;  //行高  一般和容器的高值相同放在中間  
cursor:pointer/wait;   //光標(biāo)的形狀  
    (2)背景相關(guān)的屬性  
background-color:red;  //背景顏色  
background-color:#88eeff;  //RGB格式顏色設(shè)置  
background-color:rgb(100,100,100);  //可以用這種格式輸入十進(jìn)制數(shù)的顏色值  
background-image:url(images/t1.jpg);  //背景圖片  
background-repeat:no-repeat/repeat-x/repeat-y;   //平鋪方式  
background-position:30px 20px; //(水平和垂直)背景位置  
background-attachment:scroll(默認(rèn))/fixed;  //依附方式    
也可以同時(shí)設(shè)置背景的多個(gè)特性:  
background:背景顏色 背景圖片 平鋪方式 依附方式  水平位置 垂直位置;  
    (3)邊框  
border-left:1px solid red;  
border-right:2px dotted black;  
border-bottom:  
border-top:  
border:1px solid red;  
    (4)定位  
width:100px;  
height:200px;  
margin  //外邊距  
margin-left:20px;  
margin-right:30px;  
margin-top:40px;  
margin-buttom:50px;  
可以簡(jiǎn)化為:margin:top right bottom left;  
      margin:40 30 50 20;  
padding  //內(nèi)邊距  
padding-left:  
padding-right:  
padding-top:  
padding-buttom:  
可以簡(jiǎn)化為:padding:top right bottom left;  
內(nèi)邊距會(huì)將父標(biāo)記撐開(kāi)  
     (5)浮動(dòng)  
取消標(biāo)記獨(dú)占一行的特性  
float:left/right;  //向左,向右浮動(dòng)  
clear:both;  //清除浮動(dòng)的影響  
     (6)其他  
list-style-type:none;除掉列表選項(xiàng)的小圓點(diǎn)。  
text-decoreation:underline;    //給文本加下劃線  
     (7)連接的偽樣式  
a:link{color:red} 沒(méi)有訪問(wèn)時(shí)  
a:visited{color:blue} 鼠標(biāo)放上時(shí)  
a:action{color:green} 鼠標(biāo)點(diǎn)擊時(shí)  
a:hover{color:yellow} 鼠標(biāo)離開(kāi)時(shí)

The above is a basic summary of the css we have learned before. Let’s take a look at the characteristics of css3. Open it first css3 reference manual (download address: http://download.csdn.net/detail/lxq_xsyu/6784027)

First look at border-color setting border

Related attributes: border-top- color,border-right-color,border-bottom-color,border-left-color

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<meta http-equiv="Content-Language" content="utf-8" />  
<meta name="robots" content="all" />  
<meta name="author" content="Tencent-ISRD" />  
<meta name="Copyright" content="Tencent" />  
<title>Border-color</title>  
<style>  
    div{  
        border: 8px solid #000;  
        -moz-border-bottom-colors: #555 #666 #777 #888 #999 #aaa #bbb #ccc;  
        -moz-border-top-colors: #555 #666 #777 #888 #999 #aaa #bbb #ccc;  
        -moz-border-left-colors: #555 #666 #777 #888 #999 #aaa #bbb #ccc;  
        -moz-border-right-colors: #555 #666 #777 #888 #999 #aaa #bbb #ccc;  
        padding: 5px 5px 5px 15px;  
    }  
</style>  
</head>  
<body>  
<div>在Firefox瀏覽器里能看到邊框顏色漸變效果</div>  
</body>  
</html>

This setting border is only supported on the Firefox browser, and the running effect

Xiaoqiangs road to HTML5 mobile development (4) - CSS2 and CSS3

You can see from the css3.0 reference book that css3 adds a lot of style attributes. We can refer to this manual to create a more gorgeous interface effect than css2. If we cooperate with js, we can also realize page animation production.

Let’s take a look at creating a rounded corner effect for interface elements

In order to achieve this effect in css2, we need to create two pictures. The code is as follows:

<html>  
    <head>  
        <style type="text/css">  
            a{  
                display:block;  
                height:40px;  
                float:left;  
                font-size:1.2em;  
                padding-right:0.8em;  
                background:url(images/headerRight.png) no-repeat scroll top right;  
            }  
              
            a span{  
                background:url(images/headerLeft.png) no-repeat;  
                display:block;  
                line-height:40px;  
                padding-left:0.8em;  
            }  
        </style>  
    </head>  
    <body>  
        <a href="#"><span>Box Title</span></a>  
    </body>  
</html>

Although the above method solves the problem, it adds a redundant tag. Let’s see how to solve it using css3:

<html>  
    <head>  
        <style type="text/css">  
            a{  
                float:left;  
                height:40px;  
                line-height:40px;  
                padding-left:0.8em;  
                padding-right:0.8em;  
                border-top-left-radius:8px;  
                border-top-right-radius:8px;  
                background-image:url(image/headerTiny.png);  
                backgrount-repeat:repeat-x;  
            }  
        </style>  
    </head>  
    <body>  
        <a href="#"><span>Box Title</span></a>  
    </body>  
</html>

Above It's Xiaoqiang's HTML5 mobile development road (4) - the content of CSS2 and CSS3. For more related content, please pay attention to the PHP Chinese website (www.miracleart.cn)!



Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
Handling reconnections and errors with HTML5 Server-Sent Events. Handling reconnections and errors with HTML5 Server-Sent Events. Jul 03, 2025 am 02:28 AM

When using HTML5SSE, the methods to deal with reconnection and errors include: 1. Understand the default reconnection mechanism. EventSource retrys 3 seconds after the connection is interrupted by default. You can customize the interval through the retry field; 2. Listen to the error event to deal with connection failure or parsing errors, distinguish error types and execute corresponding logic, such as network problems relying on automatic reconnection, server errors manually delay reconnection, and authentication failure refresh token; 3. Actively control the reconnection logic, such as manually closing and rebuilding the connection, setting the maximum number of retry times, combining navigator.onLine to judge network status to optimize the retry strategy. These measures can improve application stability and user experience.

Integrating CSS and JavaScript effectively with HTML5 structure. Integrating CSS and JavaScript effectively with HTML5 structure. Jul 12, 2025 am 03:01 AM

HTML5, CSS and JavaScript should be efficiently combined with semantic tags, reasonable loading order and decoupling design. 1. Use HTML5 semantic tags, such as improving structural clarity and maintainability, which is conducive to SEO and barrier-free access; 2. CSS should be placed in, use external files and split by module to avoid inline styles and delayed loading problems; 3. JavaScript is recommended to be introduced in front, and use defer or async to load asynchronously to avoid blocking rendering; 4. Reduce strong dependence between the three, drive behavior through data-* attributes and class name control status, and improve collaboration efficiency through unified naming specifications. These methods can effectively optimize page performance and collaborate with teams.

Declaring the correct HTML5 doctype for modern pages. Declaring the correct HTML5 doctype for modern pages. Jul 03, 2025 am 02:35 AM

Doctype is a statement that tells the browser which HTML standard to use to parse the page. Modern web pages only need to be written at the beginning of the HTML file. Its function is to ensure that the browser renders the page in standard mode rather than weird mode, and must be located on the first line, with no spaces or comments in front of it; there is only one correct way to write it, and it is not recommended to use old versions or other variants; other such as charset, viewport, etc. should be placed in part.

Receiving real-time data with HTML5 Server-Sent Events (SSE). Receiving real-time data with HTML5 Server-Sent Events (SSE). Jul 02, 2025 pm 04:46 PM

Server-SentEvents (SSE) is a lightweight solution provided by HTML5 to push real-time updates to the browser. It realizes one-way communication through long HTTP connections, which is suitable for stock market, notifications and other scenarios. Create EventSource instance and listen for messages when using: consteventSource=newEventSource('/stream'); eventSource.onmessage=function(event){console.log('Received message:',event.data);}; The server needs to set Content-Type to text/event

Improving SEO with HTML5 semantic markup and Microdata. Improving SEO with HTML5 semantic markup and Microdata. Jul 03, 2025 am 01:16 AM

Using HTML5 semantic tags and Microdata can improve SEO because it helps search engines better understand page structure and content meaning. 1. Use HTML5 semantic tags such as,,,, and to clarify the function of page blocks, which helps search engines establish a more accurate page model; 2. Add Microdata structured data to mark specific content, such as article author, release date, product price, etc., so that search engines can identify information types and use them for display of rich media summary; 3. Pay attention to the correct use of tags to avoid confusion, avoid duplicate tags, test the effectiveness of structured data, regularly update to adapt to changes in schema.org, and combine with other SEO means to optimize for long-term.

Explaining the HTML5 `` vs `` elements. Explaining the HTML5 `` vs `` elements. Jul 12, 2025 am 03:09 AM

It is a block-level element, suitable for layout; it is an inline element, suitable for wrapping text content. 1. Exclusively occupy a line, width, height and margins can be set, which are often used in structural layout; 2. No line breaks, the size is determined by the content, and is suitable for local text styles or dynamic operations; 3. When choosing, it should be judged based on whether the content needs independent space; 4. It cannot be nested and is not suitable for layout; 5. Priority is given to the use of semantic labels to improve structural clarity and accessibility.

Getting the user's current location with the HTML5 Geolocation API. Getting the user's current location with the HTML5 Geolocation API. Jul 02, 2025 pm 05:03 PM

When using HTML5Geolocation API to obtain user location, you must first obtain user authorization, and request and explain the purpose at the right time; the basic method is navigator.geolocation.getCurrentPosition(), which contains successful callbacks, wrong callbacks and configuration parameters; common reasons for failure include permission denied, browser not supported, network problems, etc., alternative solutions and clear prompts should be provided. The specific suggestions are as follows: 1. Request permissions when the user operation is triggered, such as clicking the button; 2. Use enableHighAccuracy, timeout, maximumAge and other parameters to optimize the positioning effect; 3. Error handling should distinguish between different errors

Understanding HTML5 Media Source Extensions (MSE) Understanding HTML5 Media Source Extensions (MSE) Jul 08, 2025 am 02:31 AM

MSE (MediaSourceExtensions) is part of the W3C standard, allowing JavaScript to dynamically build media streams, thus enabling advanced video playback capabilities. It manages media sources through MediaSource, stores data from SourceBuffer, and represents the buffering time range through TimeRanges, allowing the browser to dynamically load and decode video clips. The process of using MSE includes: ① Create a MediaSource instance; ② Bind it to an element; ③ Add SourceBuffer to receive data in a specific format; ④ Get segmented data through fetch() and append it to the buffer. Common precautions include: ① Format compatibility issues; ② Time stamp pair

See all articles