Solved

Hover Effect Not Working Properly

Posted on 2014-10-13
8
215 Views
Last Modified: 2014-10-13
I have a rounded rectangle that is on a transparent background which is square.  I have added a hover effect to this image.  The problem is that when I hover over the image the glow effect is around the transparent (square) and not the rounded rectangle.  How can I fix this so that it is around the rounded rectangle and not the square?

The site
http://www.davidschure.com/index.html

The code
<!--ZOOOOOOM-->
#zoom_img img{
height:50px;
width:50px;
-moz-transition:-moz-transform 0.1s ease-in; 
-webkit-transition:-webkit-transform 0.1s ease-in; 
-o-transition:-o-transform 0.1s ease-in;
}

#zoom_img img:hover{
-moz-transform:scale(1.25); 
-webkit-transform:scale(1.25);
-o-transform:scale(1.25);
position:relative;
z-index:1000;
-moz-box-shadow: 0 0 25px #38b8fa;
-webkit-box-shadow: 0 0 25px #38b8fa;
box-shadow: 0px 0px 25px #38b8fa; 
}

Open in new window

0
Comment
Question by:DS928
  • 4
  • 4
8 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40377214
That is your image with the black edge and square corners, the transparency is irrrelevant as it doesn't change the image from being a square

Though why use an image when you could achieve the same thing with a few lines of css.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40377227
In case that doesn't make sense...
If I have a 100px x 100px transparent image and draw a red circle with a diameter of 50px then I don't have a circle as the image - I have a 100px image, so any css is applied to the whole image
Ergo use CSS to create your boxes or get rid of the borders around the image and use css to give the image rounded corners equal the border in the image.
0
 

Author Comment

by:DS928
ID: 40377256
Thank you Gary.  But how would I do this?  How would I add the text?  The Borders?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40377279
http://jsfiddle.net/v60x3x78/1/

Use this HTML
<div class="grid_4 box-1" id="zoom_img">
<!-- Nothing here except what you want to add to the box -->
</div>

Open in new window


And this CSS
#zoom_img{
    width:300px;
    height:200px;
    border:10px solid gray;
    border-radius:15px;
}

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:DS928
ID: 40377319
This is what I did,
	<div id="zoom_img" class="grid_4 box-1">
        	This is the text that I want to add to this box.  This is more text.
        </div>

Open in new window

and
<!--ZOOOOOOM-->
#zoom_img img{
height:200px;
width:300px;
background:#FFF;
border:10px solid gray;
border-radius:15px;
-moz-transition:-moz-transform 0.1s ease-in; 
-webkit-transition:-webkit-transform 0.1s ease-in; 
-o-transition:-o-transform 0.1s ease-in;
}

#zoom_img img:hover{
-moz-transform:scale(1.25); 
-webkit-transform:scale(1.25);
-o-transform:scale(1.25);
position:relative;
z-index:1000;
-moz-box-shadow: 0 0 25px #38b8fa;
-webkit-box-shadow: 0 0 25px #38b8fa;
box-shadow: 0px 0px 25px #38b8fa; 
}

Open in new window


I see the text,  But no white background or border.  And no zoom effect.
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40377324
Remove img from these two classes - there is no image

#zoom_img img{         ----->    #zoom_img{ 

#zoom_img img:hover{         ----->    #zoom_img:hover{

Open in new window


And add to #zoom_img{}
background:#fff
0
 

Author Comment

by:DS928
ID: 40377333
I stand corrected.  I fixed the code to match yours.
0
 

Author Closing Comment

by:DS928
ID: 40377334
Great thank you Gary.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Angular 2 complaining about map file 7 53
Autoprefixer and text editors 1 24
Error in page 3 44
How to make interactive HTML code pages like w3school or Codecademy? 3 29
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now