Preventing an image from being draggable or selectable without using JS

前端 未结 8 2072
忘了有多久
忘了有多久 2020-12-04 05:28

Does anyone know of a way to make an image not draggable and not selectable -- at the same time -- in Firefox, without resorting to Javascript? Seems trivial, but here\'s th

相关标签:
8条回答
  • 2020-12-04 05:54

    You could set the image as a background image. Since it resides in a div, and the div is undraggable, the image will be undraggable:

    <div style="background-image: url("image.jpg");">
    </div>
    
    0 讨论(0)
  • 2020-12-04 05:59

    Set the following CSS properties to the image:

    user-drag: none; 
    user-select: none;
    -moz-user-select: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    
    0 讨论(0)
提交回复
热议问题