[英]Trying to highlight a section of a .png using HTML/CSS/jQuery/JavaScript
I am trying to highlight a section of a .png file using either HTML/CSS/JavaScript/jQuery.我正在尝试使用 HTML/CSS/JavaScript/jQuery 突出显示 .png 文件的一部分。 I am able to display the image, but am not sure how to highlight a particular section (I don't wish to highlight the entire image).
我能够显示图像,但不确定如何突出显示特定部分(我不想突出显示整个图像)。
At the moment, the html code that I have to display the image is quite simply:目前,我必须显示图像的 html 代码非常简单:
<img src="myImage.png" />
Nothing too extravagant.没有什么太奢侈的。
It is imperative that the portion that is to be highlighted remains visible to the user.要突出显示的部分必须对用户保持可见。 Ideally, I want the highlighting to be a set of controls that can be turned on/off by calling a particular method/function.
理想情况下,我希望突出显示是一组可以通过调用特定方法/函数来打开/关闭的控件。 Is this possible, and if so, how?
这是可能的,如果是,如何? Do I need to specify the exact coordinates of the region I wish to highlight (eg x, y, length, width)?
我是否需要指定要突出显示的区域的确切坐标(例如 x、y、长度、宽度)? I am ok with this, it's just that I'm a web design novice, and honestly don't know how to do this.
我对此没有意见,只是我是一个网页设计新手,老实说不知道该怎么做。
You could do this vis something along these lines: jsFiddle example您可以按照以下方式执行此操作: jsFiddle example
HTML HTML
<div id="container">
<img src="http://www.placekitten.com/200/200" />
<div id="highlight"></div>
</div>
CSS CSS
#container {
position:relative;
}
#highlight {
position:absolute;
width:75px;
height:75px;
top:75px;
left:75px;
background: rgba(255, 0, 0, 0.4);
}
This example positions a div above an image within a container, and sets the background to be partially transparent using rgba.此示例在容器内的图像上方放置一个 div,并使用 rgba 将背景设置为部分透明。 You can set the position, colors, opacity, etc. via JavaScript.
您可以通过 JavaScript 设置位置、颜色、不透明度等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.