带有点的padd元素
我有一个固定但可变内容的内联块元素。我想用点填充元素,直到宽度为100%。想想溢出:Ellispis,但反转。
span {
dislay: inline-block;
width: 6.27in;
/* something here to pad with dot? */
}
span:after { /* or here perhaps? */ }
<span>John Doe</span>
<span>Lorem Ipsum</span>
<span>Hello world</span>
<span>Test</span>
应该渲染
John Doe......
Lorem Ipsum...
Hello World...
Test..........
I have a inline-block element with fixed with but variable content. I want to pad the element with dots until 100% width. Think of overflow: ellispis but reversed.
span {
dislay: inline-block;
width: 6.27in;
/* something here to pad with dot? */
}
span:after { /* or here perhaps? */ }
<span>John Doe</span>
<span>Lorem Ipsum</span>
<span>Hello world</span>
<span>Test</span>
Should render
John Doe......
Lorem Ipsum...
Hello World...
Test..........
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以像以下那样做:
You can do it like below:
可以做到几种方法。
在您的情况下,最直接的可能足够,是在每条文本的底部放入一系列,作为重复的背景模式,然后通过给文本一个背景来隐藏在实际文本下方的位颜色。
这是一个示例片段:
请注意,原始跨度已被DIV替换为您的示例,在问题中显示了它们。
您可以使用一种替代方法,一个宽度为100%的伪元素(以及具有Overflow-X隐藏的父元)和相同的虚线背景。在这种情况下,虽然点不一定会排列。
There are a few ways this can be done.
The most straightforward, which may be enough in your case, is to have line of dots put in at the bottom of each line of text as a repeating background pattern and then hide the bit that goes beneath the actual text by giving the text a background color.
Here's an example snippet:
Note that the original spans have been replaced by divs as your example in the question shows them one under the other.
You could use an alternative method, an after pseudo element with 100% width (and the parent with overflow-x hidden) and the same sort of dotted background. In this case though the dots don't necessarily line up.