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

CSS3 過(guò)渡

瀏覽器支持

表格中的數(shù)字表示支持該屬性的第一個(gè)瀏覽器版本號(hào)。

緊跟在 -webkit-, -ms- 或 -moz- 前的數(shù)字為支持該前綴屬性的第一個(gè)瀏覽器版本號(hào)。


它是如何工作?

CSS3 過(guò)渡是元素從一種樣式逐漸改變?yōu)榱硪环N的效果。

要實(shí)現(xiàn)這一點(diǎn),必須規(guī)定兩項(xiàng)內(nèi)容:

  • 指定要添加效果的CSS屬性

  • 指定效果的持續(xù)時(shí)間。

實(shí)例

應(yīng)用于寬度屬性的過(guò)渡效果,時(shí)長(zhǎng)為 2 秒:

div
{
transition: width 2s;
-webkit-transition: width 2s; /* Safari */
}

注意: 如果未指定的期限,transition將沒(méi)有任何效果,因?yàn)槟J(rèn)值是0。

指定的CSS屬性的值更改時(shí)效果會(huì)發(fā)生變化。一個(gè)典型CSS屬性的變化是用戶鼠標(biāo)放在一個(gè)元素上時(shí):

實(shí)例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title>
<style> 
div
{
	width:100px;
	height:100px;
	background:red;
	transition:width 2s;
	-webkit-transition:width 2s; /* Safari */
}

div:hover
{
	width:300px;
}
</style>
</head>
<body>

<p><b>注意:</b>該實(shí)例無(wú)法在 Internet Explorer 9 及更早 IE 版本上工作。</p>

<div></div>

<p>鼠標(biāo)移動(dòng)到 div 元素上,查看過(guò)渡效果。</p>

</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

注意: 當(dāng)鼠標(biāo)光標(biāo)移動(dòng)到該元素時(shí),它逐漸改變它原有樣式


多項(xiàng)改變

要添加多個(gè)樣式的變換效果,添加的屬性由逗號(hào)分隔:

實(shí)例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title>
<style> 
div {
    width: 100px;
    height: 100px;
    background: red;
    -webkit-transition: width 2s, height 2s, -webkit-transform 2s; /* For Safari 3.1 to 6.0 */
    transition: width 2s, height 2s, transform 2s;
}

div:hover {
    width: 200px;
    height: 200px;
    -webkit-transform: rotate(180deg); /* Chrome, Safari, Opera */
    transform: rotate(180deg);
}
</style>
</head>
<body>
<p><b>注意:</b>該實(shí)例無(wú)法在 Internet Explorer 9 及更早 IE 版本上工作。</p>

<div>鼠標(biāo)移動(dòng)到 div 元素上,查看過(guò)渡效果。</div>
</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例


過(guò)渡屬性

下表列出了所有的過(guò)渡屬性:

屬性描述CSS
transition簡(jiǎn)寫(xiě)屬性,用于在一個(gè)屬性中設(shè)置四個(gè)過(guò)渡屬性。3
transition-property規(guī)定應(yīng)用過(guò)渡的 CSS 屬性的名稱。3
transition-duration定義過(guò)渡效果花費(fèi)的時(shí)間。默認(rèn)是 0。3
transition-timing-function規(guī)定過(guò)渡效果的時(shí)間曲線。默認(rèn)是 "ease"。3
transition-delay規(guī)定過(guò)渡效果何時(shí)開(kāi)始。默認(rèn)是 0。3

下面的兩個(gè)例子設(shè)置所有過(guò)渡屬性:

實(shí)例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title>
<style> 
div
{
	width:100px;
	height:100px;
	background:red;
	transition-property:width;
	transition-duration:1s;
	transition-timing-function:linear;
	transition-delay:2s;
	/* Safari */
	-webkit-transition-property:width;
	-webkit-transition-duration:1s;
	-webkit-transition-timing-function:linear;
	-webkit-transition-delay:2s;
}

div:hover
{
	width:200px;
}
</style>
</head>
<body>

<p><b>注意:</b>該實(shí)例無(wú)法在 Internet Explorer 9 及更早 IE 版本上工作。</p>



<div></div>

<p>鼠標(biāo)移動(dòng)到 div 元素上,查看過(guò)渡效果。</p>
<p><b>注意:</b> 過(guò)渡效果需要等待兩秒后才開(kāi)始。</p>

</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例

實(shí)例

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>php中文網(wǎng)(php.cn)</title>
<style> 
div
{
	width:100px;
	height:100px;
	background:red;
	transition:width 1s linear 2s;
	/* Safari */
	-webkit-transition:width 1s linear 2s;
}

div:hover
{
	width:200px;
}
</style>
</head>
<body>

<p><b>注意:</b>該實(shí)例無(wú)法在 Internet Explorer 9 及更早 IE 版本上工作。</p>

<div></div>

<p>鼠標(biāo)移動(dòng)到 div 元素上,查看過(guò)渡效果。</p>
<p><b>注意:</b> 過(guò)渡效果需要等待兩秒后才開(kāi)始。</p>

</body>
</html>

運(yùn)行實(shí)例 ?

點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例