CSS中怎么禁止選中文字

CSS中怎么禁止選中文字,很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來(lái)學(xué)習(xí)下,希望你能有所收獲。

成都創(chuàng)新互聯(lián)是一家專(zhuān)注于網(wǎng)站制作、網(wǎng)站設(shè)計(jì)與策劃設(shè)計(jì),自貢網(wǎng)站建設(shè)哪家好?成都創(chuàng)新互聯(lián)做網(wǎng)站,專(zhuān)注于網(wǎng)站建設(shè)10余年,網(wǎng)設(shè)計(jì)領(lǐng)域的專(zhuān)業(yè)建站公司;建站業(yè)務(wù)涵蓋:自貢等地區(qū)。自貢做網(wǎng)站價(jià)格咨詢(xún):18980820575

語(yǔ)法

Formal syntax: none | text | all | element

代碼如下:


(-prefix-)user-select: none;
(-prefix-)user-select: text;
(-prefix-)user-select: all;
(-prefix-)user-select: element;

示例

代碼如下:


.row-of-icons {
   -webkit-user-select: none;  /* Chrome all / Safari all */
   -moz-user-select: none;     /* Firefox all */
   -ms-user-select: none;      /* IE 10+ */</p> <p>    /* No support for these yet, use at own risk */
   -o-user-select: none;
   user-select: none;          
}

IE兼容性

目前在IE 10以及IE 10以上版本的瀏覽器可以使用-ms-user-select這個(gè)規(guī)則,但在更早版本的IE,我們只能通過(guò)javascript實(shí)現(xiàn)禁止選中文本:

代碼如下:


$(el).attr('unselectable','on')
.css({'-moz-user-select':'-moz-none',
   '-moz-user-select':'none',
   '-o-user-select':'none',
   '-khtml-user-select':'none', /* you could also put this in a class */
   '-webkit-user-select':'none',/* and add the CSS class here instead */
   '-ms-user-select':'none',
   'user-select':'none'
}).bind('selectstart', function(){
   return false;
});

看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。

本文名稱(chēng):CSS中怎么禁止選中文字
網(wǎng)站URL:http://www.muchs.cn/article28/jsodjp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、網(wǎng)站制作、App開(kāi)發(fā)、網(wǎng)頁(yè)設(shè)計(jì)公司、外貿(mào)網(wǎng)站建設(shè)、定制網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都做網(wǎng)站