0

我正在尝试用 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>吗?

感激不尽

4

2 回答 2

1

梯度不是 the 的值,background-color而是 thebackground-image

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

演示在http://jsfiddle.net/L6bQ9/

于 2013-01-02T11:52:40.653 回答
0

使用background-image而不是background-color它的工作原理

于 2013-01-02T11:51:41.977 回答