【发布时间】:2020-04-26 14:39:57
【问题描述】:
基本上我有一个项目菜单 菜单打开时会有一个图标+文本
只有关闭菜单的图标
我不确定我阅读了哪个最佳选项 + a 或按钮
我开始尝试按钮,但我遇到了问题: 我不能将文字留在图标的中心
而不是按钮中心的图标
代码:
<MenuDiv>
<ButtonContainer>
<Icon name='facebook' size='big' /> Facebook
</ButtonContainer>
</MenuDiv>
风格的组合:
export const MenuDiv = styled.div`
width: 100%;
height: 100%;
background: #d987;
padding: 6px;
display:flex;
justify-content: center;
`;
export const ButtonContainer = styled(Button)`
width: 100% !important;
height: 50px;
padding:0 !importante;
color: white !important;
text-align: left !important;
margin: 0 !important;
background-color: red !important;
`;
我想要这个:
我知道了:
codesandbox 示例: https://codesandbox.io/s/zen-goldstine-gps3s
【问题讨论】:
-
I can't leave the text in the center of the icon and not the icon in the center of the button是什么意思?有点混乱。 -
基本上文字在图标上方,看起来并不集中
-
我相信是因为我的图标没有居中我一路试了也无法修复
标签: css reactjs styled-components