Cos*_*ure 12 css reactjs 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'
})
}
Run Code Online (Sandbox Code Playgroud)
谢谢
Lau*_*ura 21
要在Select关注焦点时重置边框,您有两种解决方案:
使用 state
control: base => ({
...base,
border: state.isFocused ? 0 : 0,
// This line disable the blue border
boxShadow: state.isFocused ? 0 : 0,
'&:hover': {
border: state.isFocused ? 0 : 0
}
})
Run Code Online (Sandbox Code Playgroud)使用!important(此方法有效,但我建议使用第一个解决方案,!important绝对不是一件好事)
control: (base, state) => ({
...base,
border: '0 !important',
// This line disable the blue border
boxShadow: '0 !important',
'&:hover': {
border: '0 !important'
}
})
Run Code Online (Sandbox Code Playgroud)不要忘记重置boxShadow您得到的(蓝色边框)。
这里有一个活生生的例子。
Jef*_* S. 14
这对我有用:
control: (base, state) => ({
...base,
border: '1px solid black',
boxShadow: 'none',
'&:hover': {
border: '1px solid black',
}
})
Run Code Online (Sandbox Code Playgroud)
这将确保边框在不活动、悬停或活动时保持不变,但没有蓝色框阴影。
对于任何使用react-selectwith的人来说@tailwindcss/forms,输入上可怕的蓝线(又名框阴影)是由表单插件引入的。您需要传递strategy: class到文件中的表单插件tailwind.config.js。
plugins: [
...
require('@tailwindcss/forms')({
strategy: 'class',
}),
]
Run Code Online (Sandbox Code Playgroud)
更多相关信息: https: //github.com/tailwindlabs/tailwindcss-forms#using-only-global-styles-or-only-classes
这绝对有效:
const style = {
control: (base) => ({
...base,
boxShadow: "none"
})
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6668 次 |
| 最近记录: |