【问题标题】:How do I put a dynamic font-size based on the box-size? [duplicate]如何根据框大小放置动态字体大小? [复制]
【发布时间】:2020-12-07 00:02:21
【问题描述】:

我正在为一个大学赞助的项目制作一个基于植物学的网络问答游戏,以帮助一般高中学生。我需要文本始终填满整个框(按钮、问题回答等)以保持美观。这是它现在的样子。

How the game looks (for now)

问题文本的 CSS 是:

.question-text {
        text-align: justify;
        border: 1px solid black;
        letter-spacing: 0px;

        /* --- POSITION --- */
        position: fixed;
        top: 10%;
        left: 1%;

        /* --- SIZE --- */
        width: 75%;
        height: 20%; 
    }

有什么建议吗?我也在接受建议。

【问题讨论】:

    标签: html css dynamic font-size


    【解决方案1】:

    em 单位是使用动态字体大小的方法,它是相对于:

    父元素的字体大小,在字体大小等印刷属性的情况下,以及元素本身的字体大小,在宽度等其他属性的情况下。

        .question-text {
            // pervouis properties
            /* Font-Size */
    
            font-size: <numericAmount>em;
         }
    

    【讨论】:

      猜你喜欢
      • 2016-09-14
      • 2012-05-04
      • 1970-01-01
      • 1970-01-01
      • 2017-06-29
      • 2012-01-02
      • 1970-01-01
      • 2015-09-09
      相关资源
      最近更新 更多