Umb*_*bro 3 javascript css reactjs react-select
我正在使用react-select图书馆https://react-select.com/home#getting-started。试图将选择减少到维度width: 90px; height: 23px。但是,当您单击它时,选择增加。如何设置上述参数,使 select 有一个 cay 时间width: 90px; height: 23px?
演示在这里:https : //stackblitz.com/edit/react-sk7g4x
import Select from 'react-select'
const options = [
{ value: 'chocolate', label: 'Chocolate' },
{ value: 'strawberry', label: 'Strawberry' },
{ value: 'vanilla', label: 'Vanilla' }
]
class App extends Component {
constructor() {
super();
this.state = {
name: 'React'
};
}
render() {
return (
<Select options={options} />
);
}
}
Run Code Online (Sandbox Code Playgroud)
CSS
.css-2b097c-container {
width: 90px;
height: 23px;
font-size: 10px;
}
.css-yk16xz-control {
min-height: 23px;
}
.css-1pahdxg-control {
min-height: 23px;
}
.select__control--is-focused {
min-height: 23px;
}
.css-tu25sd-control {
height: 23px;
}
.selectSort .css-aohzbe-control {
height: 23px;
}
.selectSort .css-1hwfws3 {
padding: 0;
}
.css-tlfecz-indicatorContainer {
padding: 0;
}
.css-yk16xz-control {
height: 23px;
}
Run Code Online (Sandbox Code Playgroud)
尝试使用道具classNamePrefix。如果您不使用它,则 react-select 会创建动态前缀名称,例如css-tu25sd-c..它们不可靠。
<Select
options={options}
classNamePrefix='my-className-prefix' />
有关更多道具信息,请参阅:https : //github.com/JedWatson/react-select#props
编辑的解决方案。尝试使用classNamePrefix道具,更新您的 css 以匹配动态 css 类并在您的编辑器中运行。
h1, p {
font-family: Lato;
}
.css-2b097c-container {
width: 90px;
}
.my-className-prefix-container,
.my-className-prefix__control {
width: 90px !important;
height: 3px !important;
}
.my-className-prefix__value-container,
.my-className-prefix__indicator-separator,
.my-className-prefix__dropdown-indicator {
position: relative;
bottom: 8px;
}
.my-className-prefix__control--is-focused {
height: 23px;
}
.select__control--is-focused,
.css-1pahdxg-control {
min-height: 23px;
}
.my-className-prefix__placeholder,
.my-className-prefix__value-container,
.my-className-prefix__menu {
font-size: 10px;
}
.css-yk16xz-control {
min-height: 23px;
max-height: 23px;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2201 次 |
| 最近记录: |