I have a div which has some text content( eg: My Name ) and the div is in RED background colour
This can be done using span changing its width over the time. Here is the working fiddle. The code is displayed below. Only the mandatory styles are displayed here.
HTML
CSS
.red-button {
position: relative;
background: red;
}
span.bg-fix {
display: block;
height: 100%;
width: 0;
position: absolute;
top: 0;
left: 0;
background: blue;
transition: width 10s ease-in-out;
}
p {
position: relative;
z-index: 1
width: 100%;
text-align: center;
margin: 0;
padding: 0;
}
jQuery
$("div.red-button").click(function () {
$('span.bg-fix').css("width", "100%");
});