如何在div中为背景添加渐变色

时间:2016-09-18 14:44:38

标签: html css

嗨我想为我的div背景添加渐变色。 我试过这段代码,但它没有用



#apple {
  background: #0E5D7B;
  /* For browsers that do not support gradients */
  background: -webkit-linear-gradient(white, #0E5D7B);
  /* For Safari 5.1 to 6.0 */
  background: -o-linear-gradient(white, #0E5D7B);
  /* For Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(white, #0E5D7B);
  /* For Firefox 3.6 to 15 */
  background: linear-gradient(white, #0E5D7B);
  /* Standard syntax */
}

<div id="apple" style="height: 300px;width:auto;background-color:	 #0E5D7B; margin-top: 0px;">
</div>
&#13;
&#13;
&#13;

请告诉我如何解决这个问题

2 个答案:

答案 0 :(得分:0)

#apple{
    height: 300px;
    width:auto;
    background-color:#0E5D7B;
    margin-top: 0px;
    background:linear-gradient(white, lightblue);
}
<div id="apple">
</div>

答案 1 :(得分:-1)

只是fyi,你错过了类选择器(一个点)。对于一个类,你使用一个点,#为id。希望这有帮助

相关问题