【发布时间】:2019-11-26 09:25:06
【问题描述】:
所以我想创建一个上面有矩形可点击区域的图像。 我还需要这些区域有颜色,以便它们可以指示状态。 它们也应该是透明的,所以你可以看到它后面的图像上的内容。 这一切都很好,但现在我也想让它响应。
问题是,如果我使图像可缩放,则代表区域的自定义 div 只会保持原位,不会改变大小。
<div class="map-container">
<img class="image1" src="SOME_IMAGE" >
<div class="visibleItem" *ngFor="let item of items"
/*The default positions for 100% scaling are saved in a document*/
[ngStyle]="{
'left': item.posX + 'px',
'top': item.posY + 'px',
'width': item.width + 'px',
'height': item.height + 'px'
}"
/*The code below basically changes the background color of the partly transparent item*/
[class.served]="item.served === true"
(click)="doSomething()"
>
{{item.name}}
</div>
</div>
如果能够根据窗口大小调整图像和项目的大小,我将不胜感激。
【问题讨论】:
标签: html css image responsive-design scale