reactjs - 如何使用带有材质 ui 样式 api 的伪选择器?
问题描述
参考这个 api,到目前为止我的组件是这样的:
const ActionButton = styled(Button)({
margin: '0 16px',
});
但是现在我想使用first-child
andlast-child
伪选择器,但我不完全确定如何使用这个特定的 API 来实现它。
我试过这样的事情:
const ActionButton = styled(Button)({
margin: '0 16px',
':first-child': {
marginLeft: 0,
},
':last-child': {
marginRight: 0,
},
});
但这似乎不起作用。
有没有人尝试过这样的事情?
解决方案
我错过了最重要的部分:&
.
const ActionButton = styled(Button)({
margin: '0 16px',
'&:first-child': {
marginLeft: 0,
},
'&:last-child': {
marginRight: 0,
},
});
推荐阅读
- php - php 使用 mail() 函数从域中发送电子邮件地址的电子邮件
- python - 向客户端发送有关视图中长时间运行任务的进度的更新
- css - 将复选框与标签对齐
- android - 计费库 PurchasesResult 不包含订阅的 expiryTimeMillis,没有实时通知如何获取?
- express - Express js + Sequelize 和 hook
- javascript - 在自定义日历中自动突出显示“剩余时间”
- php - 使用下一页获取 youtube 播放列表数据,包括播放列表中的每个视频
- regex - 使用正则表达式在大查询查询中从 url 中排除 uuid
- java - 使用 JavaFx 11 机器人 API 时的 InvocatoinTargetExceptoin
- angular - 有没有办法让组件在角度 2+ 中成为单例?