首頁  >  文章  >  web前端  >  html 怎麼設定文字無法選中

html 怎麼設定文字無法選中

藏色散人
藏色散人原創
2021-11-10 14:24:326876瀏覽

html設定文字無法選取的方法:1、建立HTML頁面檔案;2、透過設定css樣式為「user-seletct: none;-webkit-user-seletct: none;-moz-user-seletct : none;」即可。

html 怎麼設定文字無法選中

本文操作環境:windows7系統、HTML5版、DELL G3電腦

html 怎麼設定文字無法選取?

控制HTML頁面內容無法選取的方法

方法有二

# 一:css 方法

user-seletct: none;
-webkit-user-seletct: none;
-moz-user-seletct: none;
-ms-user-seletct: none;

none: 無法選取內容

text: 能選取內容

二:js 方法

document.body.onselectstart = function(){
  return false;
}

回傳false,不能選取

回傳true,能選取

推薦學習:《HTML5影片教學

以上是html 怎麼設定文字無法選中的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn