admin管理员组文章数量:1405322
I want to create a page which essentially has a black and white photograph of, say, 5 people. Now, on hover over each person, I want that person to light up and a dialog of information to be displayed next to it.
Can anyone please tell me how to go about doing this?
Thanks in advance. :)
I want to create a page which essentially has a black and white photograph of, say, 5 people. Now, on hover over each person, I want that person to light up and a dialog of information to be displayed next to it.
Can anyone please tell me how to go about doing this?
Thanks in advance. :)
Share Improve this question asked Nov 13, 2012 at 10:15 FahadFahad 1,4443 gold badges21 silver badges41 bronze badges 1- you might need to use CSS sprites for this. – Om3ga Commented Nov 13, 2012 at 10:16
3 Answers
Reset to default 3Either use an image map or make "invisible" divs on top of each person. Both have their pro's and cons but an Image Map was created specifically for what you need.
To "Light them up" your only choice would be to overlay a .png image (on :hover of invisible div) with a transparent background with a cut out of that person, but edited to be "light"
html:
<a href="#" class="highlightit"><img border="0" src="http://twitter.github./bootstrap/assets/img/bootstrap-mdo-sfmoma-03.jpg">
<span> something </span>
</a>
css:
.highlightit img{
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50);
-moz-opacity: 0.5;
opacity: 0.5;
}
.highlightit:hover img{
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=100);
-moz-opacity: 1;
opacity: 1;
}
.highlightit:hover span{
display:block;
}
.highlightit span{
font-size:20px;
color:white;
background:black;
text-decoration:none;
display:none;
width:100%;
padding:10px;
position:relative;
margin-top:-20px;
}
check this fiddle for a preview http://jsfiddle/wandarkaf/cNC5G/ .
Two possible methods:
CSS Sprites
Create one large image which contains the original image plus the image in each of it's different hover states (probably stacked vertically).
Place the image as a background image of a DIV sized to show just the original image(or Figure or whatever).
Abolsutely position some links in the DIV to where you want them to be (making sure your container DIV is relatively positioned).
On hover of one of your links adjust the background position of the image to show the correct image and to display a hidden DIV/SPAN/WHATEVER containing you text dialogue.
Javascript.
- Same method as above but using separate images which are called on hover/mousein or whatever then again call a hidden dialogue to show. Plenty of tooltip plugins available for this purpose.
本文标签: javascriptHighlight parts of an image on mouseoverStack Overflow
版权声明:本文标题:javascript - Highlight parts of an image on mouseover - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744229387a2596254.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论