javascript - 是否有可能为 javascript 变量添加 nth-child?我需要将它添加到打字稿代码
问题描述
这是在 .tsx 文件中。样式变量应用为styles={styles}
var styles = {
bmBurgerBars: {
height: '10px',
right: '20px'
}
//nth child for bmBars
}
我已经尝试了下面的代码,但它没有在 UI 上实现
var styles = {
bmBurgerBars: {
height: '10px',
right: '20px',
'&:nth-child(2)': {
width: '80%',
left: '7px',
background: '#111'
}
}
}
解决方案
假设您正在使用诸如 Material UI(或类似/分叉)之类的库,您可以使用以下规范:
var styles = {
bmBars: {
height: '10px',
right: '20px',
'&:nth-child(n)': {
color: 'red'
}
}
}
推荐阅读
- java - 将 JSONObject 解析为列表 Google Volley 返回
- python - 设置python海龟的朝向线的方向
- r - 如何使用自定义分隔符将语料库分成段落
- javascript - JavaScript Switch 语句未返回正确的值
- owl - 如果包含在单独的导入中,则从 owl 本体中删除类注释
- vue.js - 如何使用通过 cdn 调用的 VueX 创建和实例化商店?
- c++ - 更改类中的字段
- c# - 带有参数的 C# SOAP OperationContract 不会出现在 WSDL 中
- android - 当用户在android中移出应用程序时,服务中的服务回调变为空
- android - 如何从 ARCore 中的 .fbx 获取多个对象之一?