0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

右クリックとドラッグドロップ禁止 css

Last updated at Posted at 2024-04-09

右クリック禁止

```oncopy=”return false” oncontextmenu=”return false”```

bodyの中に入れる。

ドラッグドロップ禁止

for ios

img {
  -webkit-user-drag: none;
}
img[draggable=true] {
  -webkit-user-drag: auto;
}

for android

*[draggable=true] img {
  -webkit-touch-callout: none;
}
<div class="contains-image" draggable="true">
  <img src="test.png" />
  <div class="protect-image"></div>
</div>
<style>
.contains-image {
  position: relative;
}

.protect-image {
  width: 100%;
  height: 100%;
  position: absolute;
  padding: 0;
  border: 0;
  top: 0;
  left: 0;
  opacity: 0;
}
</style>
0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?