Question

When the code below is run in this fiddle the elements ".title-wrap" and ".bg-wrap" appear side by side. Can any one tell me how to make it so ".bg-wrap" automatically takes up the entirety of ".wrap" with minimal css changes.

html:

<div class="wrap selected">
       <div class="title-wrap"></div>  
       <div class="bg-wrap"></div>
</div>        

css:

.selected .title-wrap{
    position:initial !important;
    text-align: center;
    height:29.42px;
    animation:titleAnimation .2s;
        -webkit-animation:titleAnimation .2s;
         -webkit-animation-fill-mode: forwards;
}

@-webkit-keyframes titleAnimation 
{
from {left:85px;top:5px}
to {left:25px;top:5px}
}

.wrap .title-wrap{
    width:202px;
    display:block;
    position:absolute;
    top:5px;
    left:85px;
    background:black;
}


.selected .bg-wrap{
    background:green;
    height:700px;
    width:100%;
    animation:bgAnimation .2s;
        -webkit-animation:bgAnimation .2s; 
         -webkit-animation-fill-mode: forwards;
}

@-webkit-keyframes bgAnimation
{
from {left:85px;top:35px;}
to {left:205px;top:0px;}
}

.wrap .bg-wrap{
    display:block;
    position:absolute;
    top:35px;
    left:85px;  
}
Was it helpful?

Solution

Not positive on what you were trying to accomplish, however I think I have the solution. I also cleaned up your code, it is now minified and easier to read. I also updated for cross browser use. Here is the updated JSFiddle with the necessary fixes: http://jsfiddle.net/mLh7r/34/

HTML:

<div class="wrap selected">
    <div class="title-wrap titleAnimation"></div>
    <div class="bg-wrap bgAnimation"></div>
</div>

CSS:

@-webkit-keyframes titleAnimation {from{left:85px;top:5px}to{left:25px;top:5px}}
@-moz-keyframes titleAnimation {from{left:85px;top:5px}to{left:25px;top:5px}}
@keyframes titleAnimation {from{left:85px;top:5px}to{left:25px;top:5px}}

@-webkit-keyframes bgAnimation {from{left:85px;top:35px;}to{left:0px;top:0px;}}
@-moz-keyframes bgAnimation {from{left:85px;top:35px;}to{left:0px;top:0px;}}
@keyframes bgAnimation {from{left:85px;top:35px;}to{left:0px;top:0px;}}

.titleAnimation {
    -webkit-animation: titleAnimation ease-in 1s;
    -moz-animation: titleAnimation ease-in 1s;
    animation: titleAnimation ease-in 1s;

    -webkit-animation-fill-mode: forwards;
    -moz-animation-fill-mode: forwards;
    animation-fill-mode: forwards;    
}
.bgAnimation {
    -webkit-animation: bgAnimation ease-in 1s;
    -moz-animation: bgAnimation ease-in 1s;
    animation: bgAnimation ease-in 1s;

    -webkit-animation-fill-mode: forwards;
    -moz-animation-fill-mode: forwards;
    animation-fill-mode: forwards;    
}
.wrap .title-wrap, .wrap .bg-wrap {
    position: absolute;
    display: block;
    left: 85px;
}
.title-wrap {
    position:absolute !important;
    text-align: center;
    height:29.42px;
}
.bg-wrap {
    height:700px;
    width:100%;
    background:green;
    z-index: -1;
}
.wrap .title-wrap {
    width:202px;
    top:5px;
    background:black;
}
.wrap .bg-wrap {
    top:35px;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top