相关疑难解决方法(0)

停止在页面加载时触发CSS3过渡

我遇到了transition在页面加载时触发的CSS 属性问题.

问题是,当我将一个color transition元素应用于(ex :) transition: color .2s时,当页面首次加载时,我的元素会从黑色闪烁到它自己指定的颜色.

假设我有以下代码:

CSS

p.green {
   color: green;
   transition: color .2s;
   -moz-transition: color .2s;
   -webkit-transition: color .2s;
   -o-transition: color .2s;
}

p.green:hover {
   color: yellow;
}
Run Code Online (Sandbox Code Playgroud)

HTML

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
    <script src="js/main.js"></script>
    <link href="css/main.css" rel="stylesheet" />
</head>
<body>
    <p class="green">The Flashing Text</p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

在页面加载,我p.green会褪色从blackgreen.

我不想将颜色过渡应用于 …

html css google-chrome

61
推荐指数
6
解决办法
3万
查看次数

标签 统计

css ×1

google-chrome ×1

html ×1