【问题标题】:Optimize button width based on content/label根据内容/标签优化按钮宽度
【发布时间】:2019-04-19 20:50:57
【问题描述】:

下面是 HTML 源代码的屏幕截图,其中一个按钮比其中的内容占据了更多的宽度。以黄色突出显示,按钮右侧有空间。我知道它是因为多线。这是跨浏览器的预期行为,是否有任何解决方案可以根据内容使用宽度?

div {
      width: 100px;
  }
  button {
      display:inline !important;
      text-align: left;
  }
<div>
  <button>
Testing Programs 
</button>
</div>

【问题讨论】:

    标签: html css button angular-material-table


    【解决方案1】:

    一般来说是的,除非你定义了它的最大高度。 你可以试试这样的。

    HTML

    <div class="parent-div">
      <p class="text">Try to change the max width in the css or remove some of the text here</p>
    </div>
    

    CSS

    .parent-div {
      max-width:600px;
      padding:10px;
      background-color:#FFF000;
      display:block;
      margin: 0 auto;
    }
    
    .text {
      font-size:5vw;
      color:#FF00FF;
      text-align:center;
    }
    

    【讨论】:

      猜你喜欢
      • 2017-12-31
      • 2017-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-24
      • 1970-01-01
      • 2013-08-16
      相关资源
      最近更新 更多