最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Overlay png image and darken image on hover - Stack Overflow

matteradmin7PV0评论

How do i make the image darken, then overlay a png image like here?

here's my current code:

<!DOCTYPE html>
<html>
<head>
<title>JQuery Effect</title>
<script type='text/javascript' src='.5/jquery.min.js?ver=3.2'></script>
</head>
<body>
<img src=".jpg"/>
</body>
</html>

How do i make the image darken, then overlay a png image like here?

here's my current code:

<!DOCTYPE html>
<html>
<head>
<title>JQuery Effect</title>
<script type='text/javascript' src='http://ajax.googleapis./ajax/libs/jquery/1.5/jquery.min.js?ver=3.2'></script>
</head>
<body>
<img src="http://i25.lulzimg./7cd053.jpg"/>
</body>
</html>
Share Improve this question edited Aug 23, 2011 at 9:07 Goliath asked Aug 23, 2011 at 9:01 GoliathGoliath 231 silver badge4 bronze badges 1
  • 2 It might be easier to help if you show what you've tried so far? – slapthelownote Commented Aug 23, 2011 at 9:04
Add a ment  | 

2 Answers 2

Reset to default 4

Put a black background-color on the image container and fade out the image on hover.

The jquery (for example) would look something like this:

$('.fadable-image').each(function(){
$(this).hover(function(){
    $(this).animate({opacity: 0.5}, 250, 'swing');
},function(){
    $(this).animate({opacity: 1}, 250, 'swing');
});
});

http://api.jquery./animate/

http://api.jquery./hover/

Could also be done with CSS pseudo classes, but then without effects.

I've taken the code straight out of the site for you to see how it's done. The + image doesn't show up as the path to the img file is unknown to me.

See here.

Post a comment

comment list (0)

  1. No comments so far