**使用css樣式模擬單選框radio的功能**
### **HTML代碼:**
~~~
<div class="address">
<form>
<ul>
<li class="top-after">
<label>聯系人</label>
<input type="text" />
</li>
<li class="top-after">
<input type="radio" name="sex" checked="checked" />
<span class="sex">先生</span>
<input type="radio" name="sex" />
<span class="sex">女士</span>
</li>
<li class="top-after">
<label>手機號</label>
<input type="text" />
</li>
<li class="top-after">
<label>收貨地址</label>
<input type="text" />
</li>
</ul>
</form>
</div>
<div class="save">
<input class="save-button" type="button" value="保存">
</div>
~~~
### **css代碼:**
~~~
body {
background: #f0eff5;
}
.address {
width: 100%;
margin-top: 10px;
background: #fff;
}
.address li {
width: 90%;
height: 48px;
margin-left: 20px;
}
.address label {
display: inline-block;
width: 70px;
height: 48px;
line-height: 48px;
color: #4b4b4b;
z-index: 10;
}
.sex {
/*display: inline-block;*/
width: 30px;
height: 48px;
margin-left: 90px;
line-height: 48px;
}
.address input[type="radio"] {
display: inline;
border: none;
position: absolute;
top: 50%;
margin-top: -8px;
margin-left: 70px;
content: "";
width: 16px;
height: 16px;
background: url(../../img/no.png) no-repeat center / 16px 16px;
}
.address input[type="radio"]:checked {
content: "";
background: url(../../img/yes.png) no-repeat center / 16px 16px;
}
.address ul li input[type="text"] {
width: 70%;
height: 48px;
z-index: 8;
border: none;
}
/*保存按鈕*/
.save {
width: 100%;
}
.save input[type="button"], .save-button {
width: 90%;
height: 48px;
margin: 30px 5%;
font-size: 16px;
background: #ffdc44;
border: 1px solid #000;
border-radius: 10px;
}
.save input[type="button"]:active {
background: #ffdc44;
color: #000;
}
~~~
### **出現的bug還有解決方案**
#### 我碰到的問題就是在移動端,radio默認的樣式還在,就是默認的框還存在。
解決方案:
在css里面加一句border:none ;取消radio默認的邊框!
~~~
border: none;
~~~
- mui框架
- toast提示框的使用
- 星級評分
- 上拉刷新和下拉加載里超鏈接失效的原因
- confirm確認框的使用
- 取消下拉刷新和上拉加載的border
- 解決使用加載的方式捕捉不到dom
- css樣式篇
- css3實現0.5像素的邊框
- css3樣式中的border-radius的圓角邊框
- css面試篇之紅色十字架
- css樣式~~用圖片模擬單選框radio的功能
- div設置絕對定位以后,文字實現居中
- 設置input里面字體顏色和大小
- js知識篇
- javascript篇~~九九乘法表
- js~跳轉提示頁面
- js~實現60秒倒計時
- 正則表達式之保留小數點后兩位小數
- 數組操作方法篇
- Array.prototype.filter()的用法
- 使用正則去除空格
- jQuery知識篇
- jQuery~~模仿radio圖片切換
- 下拉菜單的滑動效果
- jQuery點擊切換字體顏色
- jQuery實現圖片和字體圖標顏色的切換
- 左側菜單之當前點擊菜單展開,其他菜單收縮
- jQuery全選或全部不選
- 實現子菜單的收縮和展開
- 小程序
- 小程序~調用豆瓣api數據的問題
- 實現毫秒級倒計時
- 條件渲染-wx:if語句
- 實現兩個頁面共存
- wxss樣式問題
- 修改按鈕默認的border-radius
- 移動端
- 安卓底部按鈕浮上來的解決方法
- excel(xlsx) to json
- vue
- 事件
- 某個元素的點擊事件
- 阻止子事件的冒泡
- excel文件的導入功能(解析成json數據)
- iview框架
- render函數
- iview不支持鍵盤事件的解決方法
- 路由傳參
- 搜索框template的基本寫法
- watch監聽
- 路由發生變化,數據沒有更新?
- 動態組件
- 刷新組件
- 前端小功能
- 搜索框
- axios
- axios公共請求方法
- cookie的簡單使用
- 微信掃碼登錄功能
- pc端微信掃碼登錄-內嵌網頁版
- MongoDB
- 安裝與配置
- 布局
- js判斷打開是PC端還是移動端
- 自適應布局方案-視口布局
- js實現加密和解密的公共方法
- js實現正則表達式匹配的文字加上標簽
- python
- 解決pip升級不成功的原因
- Django
- runserver 失敗的原因