Animate background color like a progress bar in jQuery

前端 未结 11 2176
南笙
南笙 2021-02-05 23:11

I have a div which has some text content( eg: My Name ) and the div is in RED background colour

11条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 23:48

    I thought your looking for a "Progress Bar Animation"? try this: i believe its what your looking for - the progress bar's horizontal loading motion in a jsfiddle here:

    http://jsfiddle.net/c78vF/6/

    with a few more elements you are able to simulate that easily using the same tech everyone else is using here... jquery ui etc

    html:

    
    
    DIV

    css:

    #myDivId{
        background:red; 
        color:white; 
        padding:10px; 
        overflow:hidden; 
        position:relative;
    }
    
    .content{
        z-index:9;
        position:relative;
    }
    .progress{
        z-index;1;
        width:0px;
        height:100%;
        position:absolute;
        background:blue;
        left:0px;
        top:0px;
    }
    

    js:

    $("button").click(function(){ 
          $('.progress').animate({ width: '100%' }, 10000);
    });
    

提交回复
热议问题