/    Sign up×
Community /Pin to ProfileBookmark

Hello, how can I color the background of a div tag that fades slowly? Is there anyway without using a image?

to post a comment
HTML

11 Comments(s)

Copy linkTweet thisAlerts:
@cootheadJul 13.2013 — Hi there Harith,

this could probably be done with CSS. ?

Can you give us specific details of the effect that you require?


[i]coothead[/i]
Copy linkTweet thisAlerts:
@HarithauthorJul 13.2013 — Ya sure, the color goes from golden to light yellow and then it ends with white
Copy linkTweet thisAlerts:
@cootheadJul 13.2013 — Hi there Harith,

here is your example code...
[color=navy]
<!DOCTYPE html>
<html lang="en">
<head>

<meta charset="utf-8">

<title>gold to white</title>

<style>
body {
background-color:#f0f0f0;
}
#box {
width:486px;
height:300px;
background-color:#ffd700;
border:1px solid #000;
border-radius:10px;
margin:auto;
line-height:300px;
font-size:72px;
font-weight:bold;
color:#fff;
text-shadow:0 0 1px #000,0 0 2px #000,0 0 4px #000;
text-align:center;

<i> </i>-webkit-animation-delay:2s;
<i> </i>-webkit-animation-duration:5s;
<i> </i>-webkit-animation-name:newColor;
<i> </i>-webkit-animation-fill-mode:forwards;

<i> </i>animation-delay:2s;
<i> </i>animation-duration:5s;
<i> </i>animation-name:newColor;
<i> </i>animation-fill-mode:forwards;
}
@-webkit-keyframes newColor {
from {
box-shadow:inset 0 0 16px rgba(0,0,0,0.0);
border-color:#000;
background-color:#ffd700; <br/>
}
50% {
box-shadow:inset 0 0 16px rgba(0,0,0,0.3);
border-color:#666;
background-color:#ffffe0;
}
100% {
box-shadow:inset 0 0 16px rgba(0,0,0,0.6);
border-color:#ccc;
background-color:#fff;
}
}
@keyframes newColor {
from {
box-shadow:inset 0 0 16px rgba(0,0,0,0.0);
border-color:#000;
background-color:#ffd700; <br/>
}
50% {
box-shadow:inset 0 0 16px rgba(0,0,0,0.3);
border-color:#666;
background-color:#ffffe0;
}
100% {
box-shadow:inset 0 0 16px rgba(0,0,0,0.6);
border-color:#ccc;
background-color:#fff;
}
}
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;div id="box"&gt;TEST&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;[/color]


[i]coothead[/i]
Copy linkTweet thisAlerts:
@HarithauthorJul 13.2013 — Wow, didn't knew the code would be so long. Does it works for CSS2?
Copy linkTweet thisAlerts:
@HarithauthorJul 13.2013 — It does work. But I didn't wanted it to change wholly, I just wanted like it starts from dark at the top and as it goes down it fades.
Copy linkTweet thisAlerts:
@cootheadJul 13.2013 — Hi there Harith,

Oh I see, what you require is CSS gradient....
[color=navy]
&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;

&lt;meta charset="utf-8"&gt;

&lt;title&gt;gold to white&lt;/title&gt;

&lt;style&gt;
body {
background-color:#f0f0f0;
}
#box {
width:486px;
height:300px;
background: linear-gradient(to bottom,#ffd700,#fff);
border:1px solid #eec600;
border-radius:10px;
margin:auto;
box-shadow:10px 10px 10px rgba(0,0,0,0.4);
}
&lt;/style&gt;

&lt;/head&gt;
&lt;body&gt;

&lt;div id="box"&gt;&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;[/color]


[i]coothead[/i]
Copy linkTweet thisAlerts:
@Major_PayneJul 15.2013 — This free online gradient maker may give you other options:

CSS 3 Gradient Maker

or this one: Image Maker. Stripes and Button
Copy linkTweet thisAlerts:
@cssbuttonJul 16.2013 — you can also try this cool css3 gradient generator http://www.cssbuttoncode.com/gradient.php
Copy linkTweet thisAlerts:
@HarithauthorJul 16.2013 — Thanks guys!?
Copy linkTweet thisAlerts:
@ananthapriyaJul 17.2013 — yeah! i am also learn CSS language its vey useful to me. there are lot of color coding is available in CSS3. so you have try to these
Copy linkTweet thisAlerts:
@HarithauthorJul 18.2013 — Ya, but I know CSS2. I am planning to learn HTML5 and CSS3 ?
×

Success!

Help @Harith spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...