gpt4 book ai didi

css - 在高分模板中修剪文本(使用 CSS?)

转载 作者:太空宇宙 更新时间:2023-11-03 21:30:33 25 4
gpt4 key购买 nike

我正在构建一个高分页面模板,如果用户名和/或分数太长,想修剪用户名(最好使用 CSS)。看这张照片:

highscores page template

我可以用

white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
overflow-y:none;

要修剪用户名,但如何根据乐谱长度修剪它?

您知道如何做到这一点吗?这是我当前代码的代码笔:http://codepen.io/anon/pen/yymZGM

谢谢

最佳答案

只需将分数跨度(向右浮动)移到名称前

已更新 CODEPEN

#highscores {
width: 400px;
padding: 1em;
background-color: yellow;
margin: auto;
font-size: 1.5em;
}
#highscores .round {
font-size: 1.2em;
line-height: 1.2em;
height: 1.2em;
position: relative;
background-color: red;
padding: 0.4em 0;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
overflow-y: none;
}
#highscores .round .round-index {
padding-right: 2%;
}
#highscores .round .round-author {
font-weight: 700;
width: 60%;
}
#highscores .round .round-score {
width: 28%;
float: right;
text-align: right;
}
<div id="highscores" class="celio-black">
<p id="round-4" class="round">
<span class="round-score">75</span>
<span class="round-index">01</span>
<span class="round-author">grosbouff</span>

</p>
<p id="round-1" class="round">
<span class="round-score">75486987</span>
<span class="round-index">02</span>
<span class="round-author">I have a super long name isn't it ?</span>

</p>
</div>

关于css - 在高分模板中修剪文本(使用 CSS?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29669066/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com