【问题标题】:Make css class invalid on specified screen width使 css 类在指定的屏幕宽度上无效
【发布时间】:2017-09-13 00:10:07
【问题描述】:

我有显示图像的模式。我将模态图像的高度设置为 90%,宽度会自动缩放,因此图像不会被拉伸。但在手机上,我希望不定义height,我只想将宽度定义为 100%。如何使小屏幕上的图像高度未定义?到目前为止,我有这个代码:

.image {
  height: 80%;
}
@media only screen and (max-width: 700px){
  .image {
     width: 100%;
     /* make height not defined?!
   }
}

【问题讨论】:

    标签: html css


    【解决方案1】:

    在手机屏幕上使用height: auto;。

    @media only screen and (max-width: 700px){
      .image {
        width: 100%;
        height: auto;
       }
    }
    

    【讨论】:

    • 还是一样的结果,好像没有让第一个高度定义无效..
    【解决方案2】:
    @media only screen and (max-width: 700px){
      .image {
        width: 100%;
        height: auto;
       }
    }
    

    【讨论】:

      猜你喜欢
      • 2022-11-02
      • 2013-07-27
      • 2011-09-30
      • 1970-01-01
      • 1970-01-01
      • 2015-07-05
      • 2019-08-29
      • 1970-01-01
      • 2012-12-01
      相关资源
      最近更新 更多