<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
body{
font-family: myfamily;
font-size: 20px;
}
@font-face {
font-family: myfamily; /*字型自定義名稱,便于引用*/
/*自定義字型
*/
src:url("res/font.TTF");
/*字型的url*/
p{
transition: 500ms;
position: relative;
top: 200px;
left: 100px;
p:hover{
font-size: 70px;
color: aquamarine;
div{
width: 400px;
height: 200px;
background-color: lavenderblush;
transition: width 2s linear ; /*寬度過度時間為2s,勻速*/
div:hover{
width: 600px;
#div2{
text-align: center;
margin: auto;
line-height: 20px;;
font-size: 2px;
width: 50px;;
height: 20px;;
background-color: antiquewhite;
transition:1s; /*隻改變了背景色,過度時間為1s*/
#div2:hover{
background-color: coral;
</style>
</head>
<body>
<div id="div1">
</div>
<div id="div2">
紅米2
</body>
</html>
本文轉自 matengbing 51CTO部落格,原文連結:http://blog.51cto.com/matengbing/1875885