html - 按钮的背景颜色在移动设备上发生变化

标签 html css

我想要一个橙色的按钮,并且只在用户使用智能手机访问网站时显示。

@media only screen and (max-width: 450px) {
  .belnummobiel {
    color: #fff;
    background-color: rgb(255, 102, 0) !important;
    padding-left: 15px;
    padding-right: 15px;
    padding-bottom: 5px;
    padding-top: 5px;
    width: 100px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media only screen and (min-width: 451px) {
  .belnummobiel {
    display: none !important;
  }
}

如您所见,该按钮不应显示在该网站的桌面版本上,但可以正常工作。

奇怪的是,橙色背景不会在 Android Chrome 浏览器上显示,但当您将桌面浏览器缩放到移动尺寸时会显示,有什么想法吗?

最佳答案

您可以尝试更改您的媒体查询,因为所采用的查询不支持当前的 android 手机。目前你已经为 max-width 450 编写了,所以可能是你检查设备在 max-width 480 时是否支持的地方。你尝试下面的代码,所以它将支持 potrait 和 landscape 的 android 浏览器,并将隐藏桌面.

.belnummobiel {
display: none !important;
}

@media only screen and (max-width: 767px) { 
.belnummobiel {
color: #fff;
background-color: rgb(255, 102, 0) !important;
padding-left: 15px;
padding-right: 15px;
padding-bottom: 5px;
padding-top: 5px;
width: 100px;
margin-left: auto;
margin-right: auto;
display:block
}

关于html - 按钮的背景颜色在移动设备上发生变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50483304/

相关文章:

html - Elasticsearch作为图像服务器与Apache

javascript - 使用 html 进行 url 到 url 重定向

html - html 链接的位置显示不正确

php - 为一个 div 回显多个 css 类

html - 如何提取向下滚动时进一步加载的完整表格?

html - 如何使用 selenium webdriver 单击插入标签下的按钮

javascript - 从 PHP 服务器端脚本获取 JSON 数据并显示在下拉列表中

javascript - 显式初始化 Jquery Mobile?

Javascript 将属性拆分为对象排除在字符串中

jquery - 如何使整个div可点击?