【问题标题】:Making font size responsive with parent div width and height css使字体大小响应父 div 宽度和高度 css
【发布时间】:2017-04-24 14:53:53
【问题描述】:

我正在使用字体大小:vw;

#foti_module_wrapper .tools-nav-option i {
    color: #666666;
    font-size: 6.2vw;
}
#foti_module_wrapper .tool-nav-label {
    font-size: 3.2vw;
    line-height: 4px;
}
#foti_module_wrapper .tool-item {
    -webkit-box-flex: 1;
    -webkit-flex: 1 0 auto;
    -ms-flex: 1 0 auto;
    flex: 1 0 auto;
    display: flex;
    text-align: center;
}
#foti_module_wrapper .tools-nav-option {
    -webkit-box-flex: 1;
    -webkit-flex: 1 0 auto;
    -ms-flex: 1 0 auto;
    flex: 1 0 auto;
    padding: 10px;
    color: #292929;
    font-size: 20px;
    text-align: center;
    line-height: inherit;
    cursor: pointer;
    border: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    z-index: 2;
    background: white;
}

在移动设备上运行良好,但在平板电脑上字体图标和文本溢出了我的工具项填充...

我想避免这种情况

我想要这个结果:

【问题讨论】:

  • 您可以轻松使用媒体查询为平板电脑编写代码
  • 我不想使用媒体查询
  • 没有媒体查询的唯一方法就是js!是否有理由不使用媒体查询 - 因为它正是它的用途......
  • 你试过在字体大小中使用 % 吗?

标签: html css font-size


【解决方案1】:
#foti_module_wrapper .tool-nav-label {
    font-size: 3.2vw;
    line-height: 4px;
}

你可以使用 font-size: 3.0vh,如果你想让它也响应高度。 Vw 和 Vh 分别用于响应宽度和高度。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-11
    • 1970-01-01
    • 2012-04-26
    • 1970-01-01
    • 2016-08-30
    • 1970-01-01
    • 2015-03-01
    • 2021-10-02
    相关资源
    最近更新 更多