Solved

Zoom on background image in div on hover

Posted on 2014-02-10
4
4,396 Views
Last Modified: 2014-02-11
Hi,

I have a dive with a background-image in it. When the user hovers over it I want to add some blur tot he image and zoom in on it slightly.

I have seen this effect on another wbesite but am failing to find it at the moment

I have tried using scale in the css but this enlarges the whole div. I would preferrably like to just zoom (enlarge and animate) the background image only retaining the div size.

Could anyone help me please?
0
Comment
Question by:flynny
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 8

Expert Comment

by:Adrian Crabtree
ID: 39847622
Hi flynny,

I've set up an example using only CSS. You can view it here: http://jsfiddle.net/vCn25/3/.

If you go this route, it will not work for older browsers (IE8 and below). But as you can see, I set the background div within a wrapper. I did this so you could still have content within the wrapper without it getting blurred.
0
 

Author Comment

by:flynny
ID: 39847935
Hi,

many thanks for that that would work brilliantly. However I ran into some problems.

Because I am trying to add this on a wordpress installation I want to create the divs with these effects dynamically.

The easiest way I saw to to this was

<div class="image-wrapper">
<img src="<?php echo get_post_meta($current_page->ID, 'thumb', true); ?>"/>	
</div>

Open in new window


with the following css

.image-wrapper {
    overflow: hidden;
    position: relative;
    height: 150px;
    width: 225px;
}

.image-wrapper img { 
	position:relative;
	z-index:0;
	margin-left: auto;
    	margin-right: auto;
    	-webkit-transition: all .5s ease-in-out;
       	-moz-transition: all .5s ease-in-out;
        -ms-transition: all .5s ease-in-out;
        -o-transition: all .5s ease-in-out;
        transition: all .5s ease-in-out;
}

.image-wrapper:hover img {

	width:300px;
	margin-left: auto;
	margin-right: auto;
    	-webkit-filter: blur(40px);
       	-moz-filter: blur(40px);
        -ms-filter: blur(40px);
        -o-filter: blur(40px);
}

Open in new window


however its not animating. My idea was to centre the image and then just increase the size.

The problem I am getting is that the image is just changing to the new size and is not being centered?
0
 
LVL 8

Accepted Solution

by:
Adrian Crabtree earned 500 total points
ID: 39849157
Sorry for the last response! If you have your markup like that, you can try this: http://jsfiddle.net/vCn25/4/.

What I did here was give the <img> a specific width and height, and once you hover over the wrapper the width and height of the <img> increases. I was able to center the image by using position absolute and then adjusting the margins and the left and top properties.
0
 

Author Closing Comment

by:flynny
ID: 39850162
perfect adrian many thanks for helping me out.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question