简体   繁体   中英

How can I disable the image dragging efect?

I am working on a carousel which is working great, the only problem is that when I drag the image, a ghosting replica hovers above the image. This also happens when I drag the image container.

I tried with draggable="false" and also with user-select: none !important; but none of them worked.

How can I solve this problem?

Use the CSS selector pointer-events . So, give it the style pointer-events: none; . Here 's some more documentation on that.

Hope this helps!

做这样的事情:

 document.getElementById('drag').ondragstart = function() { return false; }; 
 <img src="https://images.pexels.com/photos/2016999/pexels-photo-2016999.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500" id="drag" /> 

Just add this to your CSS

 img{ -webkit-user-drag: none; } 

That's all you need to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM