我在我的页面中有一个图像,它作为div的背景加载。我想这个div与用户沟通,就好像它是一个<img scr="..."
。 如何让这个div可选?用户可以轻松选择img
而不是div
不含内容。我尝试了user-selectable
的不同值,但它似乎不以任何方式分割。如何使背景图像选择div?
声明:我不能使用<img src=""/>
,因为我的图片url位于css文件中。我无法使用img
标记和content
css属性,因为它在某些浏览器中无法正常工作。
div {
background: url("https://static.pychat.org/images/dark_wall.png") no-repeat 0 0;
width: 50px;
height: 50px;
margin:100px;
}
this text is selectable but image below is not. Click run snippet to see it yourself. <div></div>
听起来像是[X Y问题](http://xyproblem.info/),是JS好吗?如果你绝对不能使用标签。 – Stickers