html - 如何在标签的值内应用 css
问题描述
我有一个<label>
包含多个值,如`
label = {Student[name] + '(' + "20" + ')'}
现在我怎样才能marginLeft: '2rem'
为标签的第二个值提供一些,即
'(' + "20" + ')'
在同一个标签中。
解决方案
使它的标签内容变为:
label = '<span>' + {Student[name] + '(' + "20" + ')' + '</span>'}
然后在你的css中做类似的事情:
.my-wrapper > span {
margin-left: 2rem;
}
.my-wrapper > span:first-of-type {
margin-left: 0;
}
我认为这应该有效。将 .my-wrapper 替换为任何通用父选择器。
更新:
或在单个语句中:
.my-wrapper > span:not(:first-of-type) {
margin-left: 2rem;
}
推荐阅读
- sql-server - 从 SQL 上的链接服务器执行查询时出现“无效的对象名称”
- java - 在运行时重新加载 Maven 依赖项
- html - Custom.css 不会覆盖 bootstrap.min.css
- html - 点击时加载不同的网站,但仍在我的网站内 - 比如 Facebook
- oauth - 如何简单地获取承载令牌以向 Azure DevOps API 发送请求?
- typescript - 寻找 Electron v8 和 TypeScript 的 _working_ 简单示例
- python - 转置熊猫数据框中的第一列
- python - 如何在没有时间戳作为名称的情况下将捕获的图片保存在kivy中
- tensorflow - 如何为 CONVLSTM2D 准备数据集?
- android - 使用导航架构组件时在活动和片段之间进行通信