我想爲此HTML和CSS代碼添加一個函數。CSS技巧或javascript
HTML
<div class="switch">
<input name="sincro" type="radio" checked="checked">
<label>O</label>
<input name="sincro" type="radio">
<label>I</label>
</div>
CSS
.switch {position:relative; overflow:hidden; border:1px gray solid; background-color:white; }
.switch label {position:relative; z-index:2; float:left; width:50%; height:100%; -webkit-transition:all 0.1s ease-out; -moz-transition:all 0.1s ease-out; transition:all 0.1s ease-out; background-color:gray; }
.switch input {position:absolute; z-index:3; opacity:0; width:100%; height:100%; -moz-appearance:none; }
.switch input:hover, div.switch input:focus {cursor:pointer; }
.switch input:checked {display:none; }
.switch input {display:block; }
.switch input:first-of-type + label {left:-50%; }
.switch input:first-of-type:checked + label {left:0%; }
.switch input:last-of-type + label {right:-50%; left:auto; background-color:green; }
.switch input:last-of-type:checked + label {right:0%; left:auto; }
在實踐中,我會用圖形保持模擬ON和按鈕OFF和執行功能,以顯示和隱藏一個DIV與功能具體的ID =「」。
我試過只用CSS或JavaScript,但它完全沒有工作,因爲如果工程模擬botton隱藏和顯示不起作用...請幫助!!!
會你把你的代碼放在小提琴? –
更重要的是,你會把你的代碼的相關部分放在你的問題中嗎? –
您的問題標題不完整。 CSS或JS做什麼? – slebetman