Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Hover effect for some not all images?

Enthusiast ,
Jan 18, 2017 Jan 18, 2017

Hi - i'm using css in DW to make a hover effect on 4 images on my page.  when you point at them they brighten and they work great but there are 4 other images below these that i do not want to make the hover effect.  i'm not sure how to turn off the effect for those images.

can someone help explain how to do this?

thank you.

2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 19, 2017 Jan 19, 2017

This is being caused by something called 'specificity', that means that the css you are applying using just img in your css is overriding anything else, (not an exact definition, but it will do).

By using img:hover as the 'target' in the css it will apply the css to all images.

Remove the css selector for the img:hover completely then add this, (also try not to use '-' in your html/css, instead use '_' -

.img-header:hover {

opacity: 1.0;

}

You will notice that I have not included the IE filter code, t

...
Translate
LEGEND ,
Jan 18, 2017 Jan 18, 2017

add a class to the 4 images you wish the effect to be applied to, then change your css to this class -

html - <img class='itsname' rest of code.

css

.itsname (

your css

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 19, 2017 Jan 19, 2017

OK thanks.  Here is the hover effect CSS that works. Then note the image class below it - I just left it blank thinking that when it reads the class it will just make it appear normal:

<style>

img {

    opacity: 0.8;

    filter: alpha(opacity=80); /* For IE8 and earlier */

}

img:hover {

    opacity: 1.0;

    filter: alpha(opacity=100); /* For IE8 and earlier */

}

.img-header {

}

</style>

Here is the image code:

<img src="myimage.jpg" class="img-header" width="823" height="40" alt=""/>

Notice the class I put there.  But it does not work - the myimage keeps lighting up on hovering.  Any idea on what i'm doing wrong?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 19, 2017 Jan 19, 2017

This is being caused by something called 'specificity', that means that the css you are applying using just img in your css is overriding anything else, (not an exact definition, but it will do).

By using img:hover as the 'target' in the css it will apply the css to all images.

Remove the css selector for the img:hover completely then add this, (also try not to use '-' in your html/css, instead use '_' -

.img-header:hover {

opacity: 1.0;

}

You will notice that I have not included the IE filter code, this is because the use of IE filters disables cleartype, which will cause fuzzy text on the page, unless you know how to fix the problem do NOT use IE filters.

IE10 and below has had all support from Microsoft stopped, (even security updates) so unless there is an absolute necessity for you to support these old browsers, don't worry about them.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 19, 2017 Jan 19, 2017
LATEST

Thanks so much.  I took out the IE thing too and it works.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines