2014-04-26 29 views
1

我正在製作一個自定義樣式表來添加到doxygen輸出文件,該文件旨在使網站元素不可選,以便只選擇有用的代碼/文本。以下是刪除行號的CSS規則示例。雖然它似乎選擇了正確的類,但使用select-all或用鼠標拖動然後複製/粘貼到文本編輯器中仍然會複製行號。爲什麼會發生?此外,我如何防止它?CSS - 使Doxygen行號不可選擇

http://jsfiddle.net/b5cU2/1/

<div class="fragment"><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160;{</div> 
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160; <a class="code" href="class_talon.html#a139bb330021efa545fd6047fa291dbeb">Set</a>(output);</div> 
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160;}</div> 
<div class="ttc" id="class_talon_html_a139bb330021efa545fd6047fa291dbeb"><div class="ttname"><a href="class_talon.html#a139bb330021efa545fd6047fa291dbeb">Talon::Set</a></div><div class="ttdeci">virtual void Set(float value, uint8_t syncGroup=0)</div><div class="ttdef"><b>Definition:</b> <a href="_talon_8cpp_source.html#l00070">Talon.cpp:70</a></div></div> 
</div> 

<style> 
.lineno { 
    background-color: red !important; 
    -webkit-touch-callout: none; 
    -webkit-user-select: none; 
    -khtml-user-select: none; 
    -moz-user-select: none; 
    -ms-user-select: none; 
    user-select: none; 
} 
.line:not(.lineno) { 
    background-color: blue; 
    -webkit-touch-callout: text !important; 
    -webkit-user-select: text !important; 
    -khtml-user-select: text !important; 
    -moz-user-select: text !important; 
    -ms-user-select: text !important; 
    user-select: text !important; 
} 
</style> 
+0

是jQuery的一個選項?我認爲問題是你需要將這些CSS規則添加到.lineno的外部父,也可以在這裏找到更多信息:http://stackoverflow.com/questions/826782/css-rule-to-disable-text-選擇突出顯示 – caramba

+1

那麼'最簡單'的方法是重新設置代碼的格式,以便行號和行內容位於不同的容器中。 – SmokeyPHP

+0

我可以選擇.lineno的父母,但是會有什麼用? – Alexander

回答

0

它是關於瀏覽器如何解釋它。 Firefox做你想做的事情,匹配選擇器不能被複制。如果您選擇了WebKit中的元素,WebKit允許複製文本。

您可以隨時使用其他結構。像this

+0

任何方法來解決這個問題? – Alexander