Solved

Zoom on background image in div on hover

Posted on 2014-02-10
4
4,306 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Html date format 9 21
JS to redirect to prev page 8 25
Web page design problem 3 20
Javascript: Mouseup doesn't follow mousedown 13 38
This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…

696 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