【发布时间】:2023-02-15 05:50:04
【问题描述】:
我正在尝试使用 @mui/material/Select 呈现下拉菜单,并希望顶部边框延伸到标签旁边。现在标签和下拉 div 的右边缘之间有空白。我检查了开发工具,我唯一可以识别的边框属性是 border-radius。有没有办法让边框向上延伸到标签的边缘?
YearDropdown.js
import React from 'react';
import InputLabel from '@mui/material/InputLabel';
import MenuItem from '@mui/material/MenuItem';
import FormControl from '@mui/material/FormControl';
import Select from '@mui/material/Select';
import styled from 'styled-components';
import { BEM_Date } from 'containerMfe/Functions';
const Form = styled(FormControl)`
width: 80px;
margin-bottom: 15px!important;
& > div > div {
padding: 10px;
}
`
export default function YearDropdown({ columns, yr, handler }) {
const years = [...new Set(columns.map(date => BEM_Date(date).getFullYear()))]
return (
<React.Fragment>
<Form>
<InputLabel id='year-dropdown-label'>Year</InputLabel>
<Select
fullWidth
labelId='year-dropdown-label'
id='year-dropdown'
value={yr}
onChange={handler}
>
{years.map(year => <MenuItem key={'year-' + year} value={year}>{year}</MenuItem>)}
</Select>
</Form>
</React.Fragment>
)
}
【问题讨论】:
标签: select material-ui border