css - React-Select 移除焦点边框
问题描述
我不知道如何从反应选择中删除边框或轮廓(不确定它是哪一个),当它集中时。
customStyle = {
control: provided => ({
...provided,
height: 10,
width: 300,
padding: 10,
margin: 0,
marginLeft: 0,
border: "0px solid black",
fontSize: 13,
backgroundColor: 'white',
outline: 'none'
})
}
谢谢
解决方案
反应选择 v3
const style = {
control: base => ({
...base,
border: 0,
// This line disable the blue border
boxShadow: 'none'
})
};
这里有一个活生生的例子
反应选择 v2
要在聚焦时重置边框,Select
您有两种解决方案:
使用
state
control: (base, state) => ({ ...base, border: state.isFocused ? 0 : 0, // This line disable the blue border boxShadow: state.isFocused ? 0 : 0, '&:hover': { border: state.isFocused ? 0 : 0 } })
使用
!important
(这个可行,但我建议使用第一个解决方案,!important
这绝不是一件好事)control: base => ({ ...base, border: '0 !important', // This line disable the blue border boxShadow: '0 !important', '&:hover': { border: '0 !important' } })
不要忘记重置boxShadow
您获得的(蓝色边框)。
这里有一个活生生的例子。
推荐阅读
- ruby-on-rails - Rails action_dispatch cookie 和 flash_hash 可能不一致
- uiimageview - iOS 14.5 为什么 UIImageView 拒绝渲染从 CIImage 创建的 UIImage?
- python - 在单行中汇总多个值
- assembly - MIPS jal 不记得位置
- angular - “数字”类型的参数不能分配给自定义请求类型的参数
- c++ - 在 C++ 中通过引用返回对象
- python - jupyter notebook 中的延迟/延迟功能
- php - 如何检查字符串的第一个单词是否在 PHP 中?
- java - 如何使用 Spring MockMvc 上传文件并使用内容类型表单数据传递更多参数?
- css - 如何根据可用性应用 CSS 类?