首页 > 解决方案 > 我们如何使@media only max-width 不适用于更大的屏幕?

问题描述

我如何使它如此'保证金:0自动;' 仅适用于移动设备?无论出于何种原因,它也将其应用于台式机和 ipad。

   @media only screen and (max-width: 1024px) {
     #scrollToTopBtn{
       display: none !important;
     }
   }

   @media only screen and (max-width: 768px) {
     .card-buttons{
       margin: 0 auto;
     }
   }

边距 - 自动;将 div 中的按钮居中应用于 ipad/桌面尺寸。

标签: htmlcss

解决方案


您可以在查询中使用min-width和来更多地指定您的设备屏幕。max-width@media()

@media only screen and (min-width: 200px) and (max-width: 767px)  {
  //Put your CSS here for 200px to 767px width devices (cover all mobile portrait width //
}

推荐阅读