[英]media query not working in chrome and device but working on firefox
I am working with mobile menu, in mobile device i need mobile menu. 我正在使用移动菜单,在移动设备中我需要移动菜单。 For that i did this
为此,我这样做
<style type="text/css">
.navbar-mini-menu a {
color: #fff !important;
cursor: pointer;
display: block;
padding: 1rem 1.5rem;
text-decoration: none;
transition: background-color .16s ease-in;
}
.navbar-mini-menu a:hover { background-color: #CD5C5C; }
.navbar-mini-menu { background-color: #000; display: none; }
.navbar-mini-menu .menu-select { color: #fff; padding: 0.4rem 1.5rem; }
.navbar-mini-menu .menu-select .btn-select {
background: url("http://test.coachfxlive.com/images/mobile-icon.png") no-repeat;
cursor: pointer;
position: absolute;
height: 30px;
width: 30px;
right: 10px;
top: 10px;
}
.navbar-mini-menu .mini-menu-options { display: block; }
.navbar-mini-menu .mini-menu-options li { display: block; }
.navbar-mini-menu .mini-menu-options li .submenu { display: none; }
.navbar-mini-menu .mini-menu-options li:focus { outline: 0; }
.navbar-mini-menu .mini-menu-options li:focus > .submenu {
display: block;
-webkit-animation-name: showSubMenu;
-webkit-animation-duration: .4s;
}
.navbar-mini-menu .mini-menu-options li a { display: block; padding: 1rem 1.5rem;
}
.header {
background-color: #000;
height: auto;
left: 0;
min-height: 43px;
padding: 6px 0;
position: fixed;
top: 0;
width: 100%;
z-index: 1000
}
@media screen and (max-width: 768px) {
.header { margin: 0; }
.header { display: none; }
.navbar-mini-menu { display: block; }
.navbar-mini-menu .mini-menu-options { display: none; }
.topgap{ display: none; }
}
</style>
<div class="header">menu</div>
<div class="navbar-mini-menu">mobile menu</div>
So, it should show mobile menu in mobile, but it not affecting in chrome and mobile also. 因此,它应该在手机中显示手机菜单,但在chrome和手机中也不受影响。 Although same thing working in my other page.
虽然同一件事在我的其他页面上也起作用。
Live workin link http://test.coachfxlive.com/user 实时工作链接http://test.coachfxlive.com/user
Live not working link http://test.coachfxlive.com/shop 实时不工作链接http://test.coachfxlive.com/shop
Here is my fiddle http://jsfiddle.net/3fhgfbb2/1/ , all I added was some color to show that media query is working and changed the max-width:
to 500px so it works better with the fiddle. 这是我的小提琴http://jsfiddle.net/3fhgfbb2/1/ ,我所添加的只是一些颜色来表示媒体查询正在工作,并将
max-width:
更改为500px,因此与小提琴配合使用时效果更好。
here is the css 这是CSS
.header{width: 100%; height: 100px; background-color: blue; text-align: center;color: white;}
.navbar-mini-menu{
width: 100%;
height: 100px;
background-color: red;
text-align: center;
color: white;
display: none;
}
@media screen and (max-width: 500px) {
.header { margin: 0; }
.header { display: none; }
.navbar-mini-menu { display: block; }
.navbar-mini-menu .mini-menu-options { display: none; }
.topgap{ display: none; }
}
Issue is not with media query or bootstrap, It because of this meta tag 媒体查询或引导程序不存在问题,这是因为有此meta标签
<meta name="viewport" content="maximum-scale=1,user-scalable=yes,width=1024" >
I replaced it with this one, and it working great. 我用这个替换了它,并且效果很好。
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.