最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

css - Do I need another div to set font-size as percentage of div width? - Stack Overflow

programmeradmin0浏览0评论

I have a div and I want its font-size to be a percentage of its width.

I can mark the div with container-type: inline-size;, put in another div and set its font-size in cqw units. It works.

Is there a way to avoid adding the second div and set the font-size directly? It seems, a container width cannot be referenced by the container itself:

div.mydiv
{
    container-type: inline-size;
    font-size: 3cqw; /* Browsers look for another container above. */
}
发布评论

评论列表(0)

  1. 暂无评论