如何用一个字符填充整个div [英] How to fill an entire div with one character

查看:50
本文介绍了如何用一个字符填充整个div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要带有*字符的装饰性侧边栏,我创建了两个带有许多*的侧边栏,问题是它们的高度与网站的主要内容有关,因此有时它们太多或不够用.我想知道是否有像javascript函数之类的东西来写一个特定的字符,直到div结束".

I need decorative sidebars full of * characters, I created two side-divs with many *, the problem is that their height is relative to the main content of the site so sometimes they're too much or they aren't enough. I'll like to know if there's something like a javascript function to write a certain character until the div "ends".

谢谢

推荐答案

非JS解决方案:

用一个星号创建一个PNG,并通过CSS将该PNG用作重复的背景图片.

Create a PNG with a single asterisk and use that as repeating background image via CSS.

这意味着:

  • 您不需要知道渲染元素的大小;
  • 您不需要获取使用当前字体大小设置计算出的字符数;
  • 即使没有JS,装饰仍然可见(例如,在地铁中,其中一半页面未加载)

这篇关于如何用一个字符填充整个div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆