[英]Javascript mouseover, add border to image
I have some circle buttons on my website that I want to get a blue outline when you mouseover
.我的网站上有一些圆形按钮,当您
mouseover
时,我希望获得蓝色轮廓。
<img src="/images/example.png" onmouseover="JavascriptHere">
How would I do this?我该怎么做? The website I am trying to do this on is http://www.inglesfield.com/ .
我正在尝试执行此操作的网站是http://www.inglesfield.com/ 。 I already have a
mousedown
event to prevent image dragging, would it be possible to have both events ( mousedown
and mouseover
) independently?我已经有一个
mousedown
事件来防止图像拖动,是否可以独立地拥有这两个事件( mousedown
和mouseover
)?
you can add a css hover style on the images您可以在图像上添加 css 悬停样式
#content:hover { border: 2px solid blue; border-radius: 100px; }
by the way: instead of using ids for the images, use class="content", because ids should be unique on a html page顺便说一句:不要为图像使用 id,而是使用 class="content",因为 id 在 html 页面上应该是唯一的
just use css :hover pseudo class.. you dont need javascript for this只需使用 css :hover 伪类.. 你不需要为此使用 javascript
<img class="hover" src="http://www.hollywoodreporter.com/sites/default/files/2012/12/img_logo_blue.jpg"/>
<style> img.hover:hover {border:5px solid #555;} </style>
example: http://jsfiddle.net/orlando/Y3Ux6/示例: http : //jsfiddle.net/orlando/Y3Ux6/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.