html - 标签未完全显示在页面上
问题描述
我用 HTML/CSS 制作的悬停 aria 标签有一个小问题。如下图所示,页面上没有完全显示标题。当句子太长时,我希望句子的其余部分显示在新行上,以便您仍然可以阅读。有人可以帮忙吗?
span:hover {
position: relative;
}
span[aria-label]:hover:after {
content: attr(aria-label);
font-size: 13px;
padding: 6px 8px;
position: absolute;
font-weight: normal;
left: 20px;
top: 100%;
white-space: nowrap;
color: #000;
border: 1px solid #00adf6;
background: #FFF;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<span aria-label="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc consequat diam nec ullamcorper dapibus. Sed nunc odio, accumsan id pellentesque in, interdum quis metus."><i class="fa fa-info info-btn"></i></span>
添加一个width
或max-width
没有工作。
其他文本正在处理它。我希望 aria-label 出现在前台。
解决方案
删除white-space:nowrap
这意味着您不允许句子换行。默认值为white-space:normal
推荐阅读
- spring - Spring API + Vue JS Web 应用程序在生产中速度极慢
- angular - symfony 不在标头中获取令牌
- ios - 如何在 Swift 中拖动表格视图行但仅在单个部分中
- regex - 从文件回显到变量
- javascript - 尝试将 Spotify 推荐与 React 一起使用时出现 400 错误
- mysql - 能否根据表中的条件调整 SQL 查询(结果)?
- .htaccess - 如何通过 htaccess 缩短 URL?
- r - 使用 difftime 时出现错误“较长的对象长度不是较短对象长度的倍数”
- flutter - 带有两个大按钮的 Flutter 视图
- php - Flatten 包括,在 Laravel 5.5 中使刀片更快