作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用文档作为示例制作了一个选择控件。但是,按钮会根据所选项目的文本宽度更改其宽度。这使得控件跳来跳去,不是一个好的 UI 设计。
有没有办法指定使用 fill
或者让按钮固定宽度?虽然我在设置固定宽度方面取得了部分成功,但呈现的控件很丑陋,文本和箭头都居中,如下所示:
相反,我想要的是:
这如何用 blueprintjs 创建?
因为有人会要求 SSCCE,这正是我使用的:https://blueprintjs.com/docs/#select/select-component
编辑:
我已经能够得到我想要的结果,但看起来库本身应该处理这个问题,而不是诉诸一系列 CSS 技巧。以下 CSS 更改会产生所需的输出,但我仍然希望得到更好的答案。
.selectButton,
.selectButton > span,
.selectButton > span > div,
.selectButton > span > div > button {
width: 100%;
}
.selectButton > span > div > button {
display: inline;
}
.selectButton span.bp3-icon-caret-down {
float: right;
}
最佳答案
有一个github issue对这个。
全屏宽度
您应该使用 alignText
属性来对齐文本和图标。前任 :
<Select className="fullwidth" items={['toto', 'tata']} filterable={false} itemRenderer={renderSelectItem} onItemSelect={this.onCategoryChange.bind(this)} >
<Button text={this.state.category} alignText="left" fill="{true}" rightIcon="caret-down" />
</Select>
.bp3-popover-wrapper.fullwidth, .bp3-popover-wrapper.fullwidth > .bp3-popover-target {
display:block;
}
<Select className="fullwidth" popoverProps={{ portalClassName:"fullwidth" }} items={['toto', 'tata']} filterable={false} itemRenderer={renderSelectItem} onItemSelect={this.onCategoryChange.bind(this)} >
<Button text={this.state.category} alignText="left" fill="{true}" rightIcon="caret-down" />
</Select>
<Select className="fullwidth" popoverProps={{ usePortal: false }} items={['toto', 'tata']} filterable={false} itemRenderer={renderSelectItem} onItemSelect={this.onCategoryChange.bind(this)} >
<Button text={this.state.category} alignText="left" fill="{true}" rightIcon="caret-down" />
</Select>
.bp3-popover-wrapper.fullwidth, .bp3-popover-wrapper.fullwidth > .bp3-popover-target {
display:block;
max-width: 500px;
}
/* with portal */
.bp3-overlay.fullwidth .bp3-select-popover {
width: 500px;
}
/* without portal */
.bp3-popover-wrapper.fullwidth .bp3-select-popover {
width: 500px;
}
关于width - 如何在 Blueprintjs 中进行选择使用(或模拟)填充?或者甚至是固定宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55816690/
我是一名优秀的程序员,十分优秀!