?
Solved

Zoom on background image in div on hover

Posted on 2014-02-10
4
Medium Priority
?
4,476 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 2000 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

762 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