2014-06-10 101 views
0

我是html新手,目前已經設置了單色背景。我有代碼將背景更改爲我想要的漸變顏色,但我無法使其工作。我的代碼創建了奇異的色彩背景的部分是:在HTML中創建漸變背景

</head> 
<body>  
<!--Start of Product Banner--> 
<body style="background-color:#6e6e6e;"> 
<div class="row"> 
<div id="header_region"> 
<!--Start of Header Logo--> 
<div id="logo" class="two_thirds"> 
..... 

的漸變色和代碼,我想改變的是:

background: linear-gradient(to bottom,#6e6e6e 0%,#313131100%); 

我曾嘗試使用此代碼打得到它工作,但似乎得到正確的語法。我如何去實現這個漸變?

回答

0

一個簡單的線性梯度,從頂部到底部(#6e6e6e#313131),爲身體標記:

body { 
    background: -webkit-linear-gradient(#6e6e6e, #313131); /* For Safari 5.1 to 6.0 */ 
    background: -o-linear-gradient(#6e6e6e, #313131); /* For Opera 11.1 to 12.0 */ 
    background: -moz-linear-gradient(#6e6e6e, #313131); /* For Firefox 3.6 to 15 */ 
    background: linear-gradient(#6e6e6e, #313131); /* Standard syntax */ 
} 

,可以找到有關在CSS3 here梯度詳細信息和示例。

+0

這是你的網頁?在Firefox中看起來不錯。它對你有用嗎? –

+0

有趣,在Firefox中看起來不錯,但在Chrome中有問題。謝謝! – Ctech45

+0

好的,不客氣。 –

-1

轉到此鏈接http://www.colorzilla.com/gradient-editor/您可以像在Photoshop中一樣添加顏色,它會爲您創建漸變代碼,並在移至較舊版本的瀏覽器時正常降級。

+1

不要只是發佈一個鏈接作爲答案,如果你要鏈接到該網站,包括它會給他的代碼,他的情況:http://jsfiddle.net/HQJsC/ – MLeFevre

2

你有兩個<body>標籤,孩子有重寫CSS風格的內聯CSS,請修復它並將CSS應用到主體。

body{ 
/* your code */ 
}