<分区>
标签 javascript html css image
我想为 <img>
添加一个新标签像这样的 html 元素:
是否有一些 JS 插件可以在 CSS 中做类似的事情?
最佳答案
你可以用css做这样的事情
#par {
position: relative;
}
#par img {
width: 200px;
height: 200px;
}
#tri {
left: 0;
top: 0;
position: absolute;
width: 0;
height: 0;
border-top: 100px solid red;
border-right: 100px solid transparent;
}
#tri:before {
content: 'New';
position: absolute;
left: 23px;
top: -68px;
transform: rotate(-45deg);
}
<div id="par">
<img src="https://pixabay.com/static/uploads/photo/2016/01/23/16/02/experimental-1157660_960_720.png" />
<div id="tri"></div>
</div>
关于javascript - 在javascript中为图像创建新标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36987767/