用CSS实现单选按钮的代码是什么
Admin 2022-08-24 群英技术资讯 522 次浏览
import React from 'react' import PropTypes from 'prop-types' import CX from 'classnames' import _ from 'lodash' import './index.less' function RadioButton(props) { const { style, title, isChecked, onClick, } = props const wrapperStyle = _.assign({}, style) return ( <div className="checkbox-wrap" style={wrapperStyle} onClick={onClick} role="button" tabIndex={0} > <span className={CX({ checkbox: true, checked: isChecked === true, })} /> <span className="tip-text">{title}</span> </div> ) } RadioButton.propTypes = { style: PropTypes.object, title: PropTypes.string, isChecked: PropTypes.bool, onClick: PropTypes.func, } RadioButton.defaultProps = { style: {}, title: '', isChecked: false, onClick: _.noop, } export default RadioButton
下面是组件样式
.checkbox-wrap { display: flex; justify-content: flex-start; align-items: center; padding: 3px 0; margin-right: 24px; cursor: pointer; .checkbox { display: inline-block; box-sizing: border-box; width: 10px; height: 10px; border-radius: 50%; border: 2px solid rgba(79, 159, 255, 1); position: relative; &.checked { &::before { content: ''; display: block; width: 4px; height: 4px; border-radius: 50%; background-color: #56afff; position: absolute; top: 1px; left: 1px; } } } .tip-text { opacity: 0.4; line-height: 18px; margin-left: 3px; } }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
在这种情况下,这个框称为无名块框,因为它不与专门定义的元素相关联。块级元素的文本行也会发生类似的情况。假设有一个包含三行文本的段落。每行文本形成一个无名框。无法直接对无名块或行框应用样式,因为没有可以应用样式的地方(注意,行框和行内框是两个概念)。但是,这有助于理解在屏幕上看到的所有东西都形成某种框 ...
小编今天来给大家说说看css3截图的实现代码内容,一般的视频网站对于用户上传的视频,在用户上传完成后,可以对播放的视频进行截图,然后作为视频的展示图。有需要的朋友可以参考。
css中clear属性的介绍:1、用于规定元素哪一侧不允许浮动元素,默认值为none,表示不清除,左右两侧允许浮动元素。2、确保当前元素的左右两侧没有浮动元素。clear只对元素本身的布局起作用。
最近,遇到了CSS在使用transform后出现字体模糊的情况,对此针对这个问题给大家分享一下该如何解决?解决方法是什么?废话不多说,下面我们来看代码。
css3通过scale()实现放大功能、通过rotate()实现旋转功能,下面有个示例,大家可以参考下
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008