【发布时间】:2022-01-06 09:55:36
【问题描述】:
我有一个像下面这样的网格列表,但问题是列有不同的widths。这是因为里面的文本长度不同。我能以某种方式忽略里面的文字,让列的宽度相同吗?
<Container>
{elements.map((e, i) => (
<StyledLabel key={i}>
<StyledInput
type="radio"
/>
<Option>{e.text}</Option>
</StyledLabel>
))}
</Container>
const Option = styled.span`
display: flex;
border: 1px solid grey;
height: 30px;
font-size: 14px;
cursor: pointer;
color: grey;
align-items: center;
justify-content: center;
box-sizing: border-box;
overflow: hidden;
text-transform: uppercase;
width: 1fr;
`;
const StyledLabel = styled.label`
cursor: pointer;
`;
const StyledInput = styled.input`
display: none;
`;
const Container = styled.div`
width: 300px;
display: grid;
grid-gap: 5px;
grid-template-columns: auto auto;
`;
【问题讨论】:
-
能否包含一个代码框,以便我们通过运行进行检查?
标签: javascript html css reactjs grid