css - 如何在反应样式的组件中添加“标题”标签(用于工具提示)
问题描述
我在我的反应应用程序中使用样式组件我想在我的样式组件上添加标题属性(用于工具提示)
我尝试使用包装器 div html 元素并在其上应用标题标签但无法做到,也尝试使用 css`` 样式的组件助手无法做到。
my styled components: (with ellipsis):
const FilterTitle = styled.div`
display: inline-block;
width: 100%;
line-height: 40px;
height: 40px;
color: ${blackChosen};
font-family: Poppins;
font-size: 16px;
letter-spacing: 0.15px;
padding-left: 15px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-weight: ${props => (props.chosen) ? '500' : 'initial'};
`;
and:
<FilterTitle> I might be a long sentence shown with ... and the title tag should tooltip me</FilterTitle>
解决方案
<FilterTitle>
仍在渲染 a div
,因此您可以将所需的任何属性直接放在该组件上,它们将被传递给 div:
<FilterTitle title="A long sentence, eh?">...
推荐阅读
- mysql - 如何在 che.openshift.io 上托管的 eclipse che 上使用数据库获取持久工作区
- mongodb - MongoDB中的项目字段,我不知道中间字段名称
- git - 为什么我删除了冲突文件,但仍然无法从远程 git pull?
- spring - 使用 JooQ 获取一对多关联
- python - 如何在 Pymc3 中定义瑞利先验?
- javascript - 对于每个触发器,如何在其触发器上动态显示 bootstrap-5 模态位置
- robotframework - 带有额外 / 的 HTTPSConnectionPool
- sql - Postgres / Postgis 查询优化
- javascript - 获取包含数组所有id的数据
- python - 当作为参数传递给“密集”层时,为什么“input_shape”不包括批次维度?