Repeated Dotted Image Background displaying in different sizes in different areas even with same CSS

Rather than using images, you could use `repeating-linear-gradient` to create the dots you're after instead? It should resize better. .dot-text { display: flex; font-size: 2rem; /*You'll probably want to do some calcs here to size this custom property with your font size */ --dot-size: 4px; --dot-spacing: 6px; } .dot-text:after { content: " "; flex-grow: 1; background-image: repeating-linear-gradient(90deg, gray 0, gray var(--dot-size), transparent var(--dot-size), transparent calc(var(--dot-spacing) + var(--dot-size))); background-repeat: no-repeat; background-position: bottom 0.45rem left 0.5rem; background-size: 100% var(--dot-size); }
This is some text
Edited to add: To apply different sizes e.g. in your example, set custom properties in the parent element .outer { color: #000; } .outer a { text-decoration: none; color: inherit; } .outer [class^="heading"] { margin-block: 0; font-weight: 400; border-left-width: 4px; border-left-style: solid; display: flex; } .heading1 { --dot-size: 4px; font-size: 23px; line-height: 34px; border-left-color: #000; padding-left: 10px; } .heading2 { --dot-size: 3px; font-size: 19px; line-height: 28px; border-left-color: #006da3; padding-left: 10px; color: #006da3; margin-left: 15px; } .heading3 { --dot-size: 2px; font-size: 17px; line-height: 25px; border-left-color: #2690cd; padding-left: 10px; margin-left: 30px; } .outer [class^="heading"]:after { content: ""; --dot-spacing: calc(var(--dot-size) * 1.5); flex-grow: 1; background-image: repeating-linear-gradient(90deg, gray 0, gray var(--dot-size), transparent var(--dot-size), transparent calc(var(--dot-spacing) + var(--dot-size))); background-repeat: no-repeat; background-position: bottom 0.5rem left 0.5rem; background-size: 100% var(--dot-size); }
  • 9
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值