CSS expanding image

Discussion in 'HTML & Website Design' started by MaxTitan, Jul 15, 2013.

  1. #1
    Say I had a 500px wide by 200px high box with an image, and when you hover over it it expands into the full image. How would I do that?
     
    Solved! View solution.
    MaxTitan, Jul 15, 2013 IP
  2. #2
    Pure CSS


    <div id="mov"></div>
    HTML:
    
    #mov {
        background: url("small.png") no-repeat scroll center top transparent;
        height: 250px;
        width: 250px;
    }
    #mov:hover {
        background-image: url("big.png");
        height: 500px;
        width: 500px;
    }
    
    Code (markup):
     
    GMF, Jul 16, 2013 IP
  3. MaxTitan

    MaxTitan Member

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #3

    thank you for the information, I am still learning and this seems like it would be something straight forward XD. My one question is what does scroll do?
     
    MaxTitan, Jul 16, 2013 IP
  4. GMF

    GMF Well-Known Member

    Messages:
    855
    Likes Received:
    113
    Best Answers:
    19
    Trophy Points:
    145
    #4
    The "scroll" value is the default value for background (meaning you don't need to define it).

    What it does - It declares whether the background should scroll with the rest of the page.

    The other value would be be fixed, so it wont scroll...
     
    GMF, Jul 16, 2013 IP
  5. MaxTitan

    MaxTitan Member

    Messages:
    29
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #5
    so if i were to add the scroll would this make the image retract back up slowly? based on this code

    #mov {
    background: url(pics/small.png) no-repeat scroll center top transparent;
    height: 250px;
    width: 2560px;
    -webkit-transition: background .5s ease;
    -moz-transition: background .5s ease;
    -ms-transition: background .5s ease;
    -o-transition: background .5s ease;
    transition: background .5s ease;
    }
    #mov:hover {
    background-image: url(pics/big.png);
    height: 1600px;
    width: 2560px;
    }
     
    MaxTitan, Jul 16, 2013 IP
  6. GMF

    GMF Well-Known Member

    Messages:
    855
    Likes Received:
    113
    Best Answers:
    19
    Trophy Points:
    145
    #6
    Never worked with transition, but what exactly do you mean with "retract back slowly"?

    Did a bit of testing, and I think I have something that might be exactly what you want. If not, describe it again.
    
    #mov {
        background: url("small.png") no-repeat scroll center top transparent;
        height: 250px;
        width: 250px;
        transition: height 0.5s ease 0s, width 0.5s ease 0s;
        -moz-transition: height 0.5s ease 0s, width 0.5s ease 0s;
        -ms-transition: height 0.5s ease 0s, width 0.5s ease 0s;
        -o-transition: height 0.5s ease 0s, width 0.5s ease 0s;
        -webkit-transition: height 0.5s ease 0s, width 0.5s ease 0s;
    }
    #mov:hover {
        background-image: url("big.png");
        height: 500px;
        width: 500px;
    }
    
    Code (markup):
    Quick breakdown
    transition: ##What changes## ##How fast is the change## ##I have no Idea what ease does## ##Delay##

    More info about css3 transition
    http://www.w3.org/TR/css3-transitions/
    Code (markup):
     
    GMF, Jul 17, 2013 IP