How can I set my image's hover when hovering my text?

user2088807

I have the following html :

<a href="link.html" >
        <img src="image.png class="bw" ></img>
        Some text
    </a>

And the css associated :

.bw { /* Effects on images */
  -webkit-transition: all 0.3s cubic-bezier(1.000, 0.835, 0.000, 0.945);
     -moz-transition: all 0.3s cubic-bezier(1.000, 0.835, 0.000, 0.945);
       -o-transition: all 0.3s cubic-bezier(1.000, 0.835, 0.000, 0.945);
      -ms-transition: all 0.3s cubic-bezier(1.000, 0.835, 0.000, 0.945);
          transition: all 0.3s cubic-bezier(1.000, 0.835, 0.000, 0.945);
}
.bw:hover {
  -webkit-filter: grayscale(100%);
  border: 5px solid #808080;
  border-radius: 50%;
}

So when I put my mouse over my image it becomes gray and this is what is expected. However, my text and my image are parts of the link. When my mouse is over my image the text is underlined, but it's not working in the other way. I would like my image to become gray when my mouse is over the text.

How can I achieve that ? So I would like all the elements contained in the to become hovered if one of them is hovered.

Akshay

Check this FIDDLE You just had to add this

a:hover {
text-decoration:underline;
}

.bw {
    /* Effects on images */
    -webkit-transition: all 0.3s cubic-bezier(1.000, 0.835, 0.000, 0.945);
    -moz-transition: all 0.3s cubic-bezier(1.000, 0.835, 0.000, 0.945);
    -o-transition: all 0.3s cubic-bezier(1.000, 0.835, 0.000, 0.945);
    -ms-transition: all 0.3s cubic-bezier(1.000, 0.835, 0.000, 0.945);
    transition: all 0.3s cubic-bezier(1.000, 0.835, 0.000, 0.945);
}
a:hover img {
    -webkit-filter: grayscale(100%);
    border: 5px solid #808080;
    border-radius: 50%;
}
a:hover {
    text-decoration:underline;
}
a {
    text-decoration:none;
}

a{
    display:inline-block;
}
<a href="link.html">
        <img src="http://placekitten.com/300/301" class="bw" ></img>
        Some text
    </a>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I set my image's hover when hovering my text?

From Dev

How do I change the opacity of an image when I hover of my text?

From Dev

How can I stop my cursor changing to an I bar when I hover over text in a table?

From Dev

How can I make text in my td wrap when it reaches the width of the image in my td?

From Dev

How can I make my disabled button not change color when there's a hover with CSS?

From Dev

How can I make my disabled button not change color when there's a hover with CSS?

From Dev

When using custom cursors, how can you set the I-bar cursor when hovering over text?

From Dev

Wrong image is set in my tableview cell sometimes when I scroll on my tableview. How can I fix this?

From Dev

In Labview how can I change the mouse pointer when hovering over one of my boolean controls?

From Dev

How can I set the default image used when my page is shared on Facebook?

From Dev

How can I set the default image used when my page is shared on Facebook?

From Dev

how to show hover effect on a image where i hover my mouse

From Dev

How can I activate the window my mouse is currently hovering over?

From Dev

How can I bring my text to the front and leave the image on the background?

From Dev

With CSS is there a way I can make my cursor change to a finger when I hover over a button if it's not disabled?

From Dev

How Can I show my own text when no node is visible

From Dev

How Can I show my own text when no node is visible

From Dev

why does my image move when i hover over it

From Dev

How can I set my UITableView's Header to an Attributed String?

From Dev

How can I force my checkbox's text to not wrap?

From Dev

how can I make my image (down arrow) disappear when I start scrolling my page?

From Dev

How can I make text appear when hovering a picture that has already the hovering for transform?

From Dev

How can I get my text to hug around the top of my image?

From Dev

Why can't I center my image even when I set img as block element?

From Dev

How can I make my Anchorpane in JAVAFX draggable when my frame is set to UNdecorated?

From Dev

There's a white blur on my cover image of my website in mobile mode. How can i remove it?

From Dev

How do I align my text div next to my image?

From Dev

Why do the icons in my footer move when I hover over the third image on my homepage?

From Dev

How can I insert an image into my database?

Related Related

  1. 1

    How can I set my image's hover when hovering my text?

  2. 2

    How do I change the opacity of an image when I hover of my text?

  3. 3

    How can I stop my cursor changing to an I bar when I hover over text in a table?

  4. 4

    How can I make text in my td wrap when it reaches the width of the image in my td?

  5. 5

    How can I make my disabled button not change color when there's a hover with CSS?

  6. 6

    How can I make my disabled button not change color when there's a hover with CSS?

  7. 7

    When using custom cursors, how can you set the I-bar cursor when hovering over text?

  8. 8

    Wrong image is set in my tableview cell sometimes when I scroll on my tableview. How can I fix this?

  9. 9

    In Labview how can I change the mouse pointer when hovering over one of my boolean controls?

  10. 10

    How can I set the default image used when my page is shared on Facebook?

  11. 11

    How can I set the default image used when my page is shared on Facebook?

  12. 12

    how to show hover effect on a image where i hover my mouse

  13. 13

    How can I activate the window my mouse is currently hovering over?

  14. 14

    How can I bring my text to the front and leave the image on the background?

  15. 15

    With CSS is there a way I can make my cursor change to a finger when I hover over a button if it's not disabled?

  16. 16

    How Can I show my own text when no node is visible

  17. 17

    How Can I show my own text when no node is visible

  18. 18

    why does my image move when i hover over it

  19. 19

    How can I set my UITableView's Header to an Attributed String?

  20. 20

    How can I force my checkbox's text to not wrap?

  21. 21

    how can I make my image (down arrow) disappear when I start scrolling my page?

  22. 22

    How can I make text appear when hovering a picture that has already the hovering for transform?

  23. 23

    How can I get my text to hug around the top of my image?

  24. 24

    Why can't I center my image even when I set img as block element?

  25. 25

    How can I make my Anchorpane in JAVAFX draggable when my frame is set to UNdecorated?

  26. 26

    There's a white blur on my cover image of my website in mobile mode. How can i remove it?

  27. 27

    How do I align my text div next to my image?

  28. 28

    Why do the icons in my footer move when I hover over the third image on my homepage?

  29. 29

    How can I insert an image into my database?

HotTag

Archive