【问题标题】:CSS: how to create button width 100% on mobile only? [duplicate]CSS:如何仅在移动设备上创建 100% 的按钮宽度? [复制]
【发布时间】:2020-11-07 03:46:31
【问题描述】:

我的问题很简单,我目前有一个简单按钮的 CSS。

我只想知道当用户使用他们的移动设备时我可以输入什么,以便它的宽度变为 100%(而不是 33%)。 (当他们的屏幕设置在一定宽度时)

非常感谢您的宝贵时间!

button {
    text-align: left;
    display: inline;  
    font-size: 2vw;
    padding: 2em;
    margin-top: 0;
    width: 33%;
    height: 100%;
    background-color: #5e75b4;
    border: none;
}

【问题讨论】:

标签: html css


【解决方案1】:

您可以为此使用mediaqueries

就像添加到你的 CSS 一样简单:

@media (max-width: XXXpx) { /*"xxx" the width of window*/
  button  {
    width:100%;
  }
}

【讨论】:

    猜你喜欢
    • 2015-05-07
    • 1970-01-01
    • 2013-08-27
    • 1970-01-01
    • 2013-06-07
    • 1970-01-01
    • 2016-10-01
    • 2018-08-08
    • 1970-01-01
    相关资源
    最近更新 更多