颜色渐变不显示

时间:2013-01-02 11:38:33

标签: css linear-gradients

我正在尝试用html编写pH范围,包括颜色。我希望颜色从酸性平滑过渡到碱性(从刻度的顶部到底部)。但是,pH值没有显示。这是html代码:

<!DOCTYPE html>
<html>
<head>
    <link rel = "STYLESHEET" type = "text/css" href = "Ph.css">
    <title >Ph SCALE</title>
    <h1 class = "Ph">THE pH SCALE</h1>
</head>
<body>
    <div>
        <p class = "zero">0.0 very acidic</p>
        <p class = "one">1.0</p>
        <p class = "two">2.0</p>
        <p class = "three">3.0</p>
        <p class = "four">4.0</p>
        <p class = "five">5.0</p>
        <p class = "six">6.0</p>
        <p class = "seven">7.0 neutral</p>
        <p class = "eight">8.0</p>
        <p class = "nine">9.0</p>
        <p class = "ten">10.0</p>
        <p class = "eleven">11.0</p>
        <p class = "twelve">12.0</p>
        <p class = "thirteen">13.0</p>
        <p class = "fourteen">14.0 very alkaline</p>
    </div>
</body>
</html>

以下是我的CSS代码。我使用-webkit-gradient作为颜色渐变:

* {
     background-color: #ccc;
 }

 h1.Ph {
     background-color: white; font-family: Arial; padding: 20px; 
     text-decoration:underline;
     text-align: center;
 }

 p {
    padding: 5px; margin: 0px;
    text-align: center;
 }

 div {
    background-color: -webkit-gradient(top, bottom,rgb(238,62,128), rgb(0,136,221));
    font-family: Courier;
 }

您能否解释为什么<div>的顶部到底部没有颜色渐变?

感激 Saad的

2 个答案:

答案 0 :(得分:1)

渐变不是background-color的值,而是background-image

的值
background-image: -webkit-linear-gradient(top,rgb(238,62,128), rgb(0,136,221));

http://jsfiddle.net/L6bQ9/

演示

答案 1 :(得分:0)

使用background-image代替background-color,它可以正常使用