(切图笔记)通用的纯css3实现 单选框radio复选框checkbox的美化 附代码 亲测好用

切图笔记记录切图网日常,说到网页的表单美化 通常需要用到插件,因为 select,radio,checkbox比较特殊,无法通过css直接美化 ,这些也有比较不错的美化插件 可以实现,不过这都是早几年的情况,现在浏览器日益更新升级,对于html5 css3标准支持的更好,使得我们现在可以通过css3也可以进行美化,没有插件参与,就可以省事不少,同时也可以让页面代码更加简洁,用到了图片背景,不过是基于data:image 方式直接引用的,所以不用到实体图片。

复制以下代码即可实现 单选 复选美化,亲测好用。

input[type=”radio”],
input[type=”checkbox”]{

width: 1em;
height: 1em;
margin-top: 0;
vertical-align: top;
appearance: none;
background-color: #fff;
background-image: var(–bs-form-check-bg-image);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
border: 2px solid #e6e6e6;
print-color-adjust: exact;
cursor: pointer;

border-width: 0.125rem;
width: 1.25rem;
height: 1.25rem;
border-color: #e7e7e7;

}
input[type=”radio”]:active,
input[type=”checkbox”]:active{

filter: brightness(90%);
}
input[type=”radio”]:focus,
input[type=”checkbox”]:focus{
border-color: #fd7e14;
box-shadow: rgba(253, 126, 20, 0.1);
}
input[type=”radio”]{

border-radius: 50%;
}
input[type=”checkbox”]{

border-radius: 0.25em;
}
input[type=”radio”]:checked{
background-color: #fd7e14;
border-color: #fd7e14;
background-image: url(“data:image/svg+xml,<svg xmlns=’http://www.w3.org/2000/svg’ viewBox=’-4 -4 8 8′><circle r=’2′ fill=’%23fff’/></svg>”);

}
input[type=”checkbox”]:checked{
background-color: #fd7e14;
border-color: #fd7e14;
background-image: url(“data:image/svg+xml,<svg xmlns=’http://www.w3.org/2000/svg’ viewBox=’0 0 20 20′><path fill=’none’ stroke=’%23fff’ stroke-linecap=’round’ stroke-linejoin=’round’ stroke-width=’3′ d=’m6 10 3 3 6-6’/></svg>”);
}

  • 20
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 uniapp 中实现一个搜索框的切图可以按照以下步骤进行: 1. 在页面中添加一个输入框和一个搜索按钮,可以使用 uniapp 提供的 `<input>` 和 `<button>` 标签。例如: ```html <view class="search-container"> <input type="text" placeholder="请输入关键字" class="search-input" /> <button type="button" class="search-btn">搜索</button> </view> ``` 2. 根据设计稿的要求,设置输入框和搜索按钮的样式,例如: ```css .search-container { display: flex; align-items: center; padding: 10px; background-color: #f5f5f5; } .search-input { flex: 1; height: 30px; border: none; outline: none; background-color: #fff; border-radius: 5px; padding: 0 10px; font-size: 14px; } .search-btn { width: 60px; height: 30px; margin-left: 10px; background-color: #409eff; color: #fff; border: none; border-radius: 5px; font-size: 14px; } ``` 3. 在页面的 `script` 中添加搜索功能,例如: ```javascript export default { data() { return { keyword: '' } }, methods: { search() { // 执行搜索操作,如跳转到搜索结果页面等 console.log('搜索关键字:' + this.keyword) } } } ``` 4. 将输入框和按钮与 `data` 中的 `keyword` 绑定,以便获取用户输入的关键字。例如: ```html <input type="text" placeholder="请输入关键字" class="search-input" v-model="keyword" /> <button type="button" class="search-btn" @click="search">搜索</button> ``` 这样,在用户输入关键字后,点击搜索按钮即可触发 `search` 方法,执行搜索操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值