選中文字時,如何避免出現藍色背景
我用span 標簽做成了 ?按鈕的樣式,如下圖中的開始和停止 按鈕,每次鼠標滑過,選中按鈕種的文字時總會使文字出現藍色背景,如下圖。請問如何設置標簽的Css樣式,可以避免這種情況的出現?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>抽獎系統</title>
<link rel="stylesheet" type="text/css" href="choujiang.css">
<script type="text/javascript" src='choujiang.js'></script>
</head>
<body>
<div>
<div id='title'>抽獎開始</div>
<div class='action'>
<span id='start' class='btn'>開始</span>
<span id='stop' class='btn'>停止</span>
</div>
</div>
</body>
</html>
-------------------------------------------------------------------------------------------------------------------------------
*{
margin: 0;
padding: 0;
}
#title{
font-size: 30px;
text-align: center;
color: red;
font-family: '微軟雅黑';
margin-top: 20px;
}
.btn{
display: block;
font-size: 20px;
font-family: 'microsoft yahei';
width: 80px;
float:left;
border:1px solid #aaa;
text-align: center;
border-radius: 10px;
background-color: #ff00ff;
color: #fff;
cursor: pointer;
}
#start{
margin-right:30px;?
}
.action{
width:194px;
height: 30px;
margin: 40px auto;
}
2016-09-21
問題已經,解決了,謝謝各位朋友的幫助
解決方案:
/*設置文字不能被選中 ? ? 以下為css樣式*/
-webkit-user-select:none;
? ?-moz-user-select:none;
? ?-ms-user-select:none;
? ?user-select:none;
2016-09-21
貼代碼上來大家看看
2016-09-21
改成button試試
2016-09-20
定義 display:block; ?塊級元素了嗎? ?最好有附上 你的代碼