html - 請(qǐng)問(wèn)css 中一個(gè)元素能做出這種選中效果么?
問(wèn)題描述
如果做不出,也可以兩個(gè)元素,最好不要絕對(duì)定位
問(wèn)題解答
回答1:首先是不太可能只用一個(gè)元素,因?yàn)橄胍獙?shí)現(xiàn)自定義的 radio 或是 checkbox 時(shí),都得靠 label 的 for 來(lái)實(shí)現(xiàn),就是隱藏實(shí)際 input ,然後自定義 label 的樣式來(lái)實(shí)現(xiàn),所以至少得兩個(gè)。
實(shí)現(xiàn)<input name='radios' type='radio' /><label for='radio1'></label><input name='radios' type='radio' /><label for='radio2'></label>
.circle-radio { visibility: hidden;}.circle-radio + label { display: block; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #00AAFF;}.circle-radio:checked + label { display: block; background: #00AAFF; box-shadow: inset 0px 0px 0px 6px white;}回答2:
如果只是單純的表示這樣一個(gè)圖形的話,單個(gè)p是可以實(shí)現(xiàn)的,即通過(guò)背景的徑向漸變
<p id='a'></p><style> #a{width:100px;height:100px;border-radius:50%;background: -webkit-radial-gradient( #0af 0%,#0af 25%,transparent 26%,transparent 60%, #0af 61%, #0af 100%); }</style>
上述代碼是運(yùn)行結(jié)果請(qǐng)看http://jsbin.com/vunoraxoko/e...
當(dāng)然,如果你是想表示radio等單選或復(fù)選的話單個(gè)元素恐怕不能滿足你的要求
對(duì)于這一點(diǎn),你可以參考樓上 @Tomoe 的回答
回答3:<p class='outer'><p class='inner'></p> </p>
.outer { width: 100px; height: 100px; margin: 0 auto; border: 3px solid blue; border-radius: 50px;}.inner { display: none; width: 50%; height: 50%; margin: 0 auto; margin-top: 25%; border-radius: 25px; background-color: blue;}p.outer:hover p.inner{ display: block;}
使用 border-radius 和 css 偽類(lèi)選擇器 :hover預(yù)覽
相關(guān)文章:
1. docker綁定了nginx端口 外部訪問(wèn)不到2. docker網(wǎng)絡(luò)端口映射,沒(méi)有方便點(diǎn)的操作方法么?3. docker容器呢SSH為什么連不通呢?4. thinkphp5.1學(xué)習(xí)時(shí)遇到session問(wèn)題5. nignx - docker內(nèi)nginx 80端口被占用6. angular.js - angular內(nèi)容過(guò)長(zhǎng)展開(kāi)收起效果7. macos - mac下docker如何設(shè)置代理8. php - 第三方支付平臺(tái)在很短時(shí)間內(nèi)多次異步通知,訂單多次確認(rèn)收款9. docker images顯示的鏡像過(guò)多,狗眼被亮瞎了,怎么辦?10. 前端 - ng-view不能加載進(jìn)模板
