简体   繁体   English

侧边栏在移动设备上定位的CSS问题

[英]CSS Issue with sidebar positioning on mobile device

I've got a problem with sidebar menu. 边栏菜单出现问题。 On some android devices like Samsung Galaxy Note 2 and in chrome browser position: fixed and actual position of menu fails and the menu is showed on my website. 在某些Android设备(如Samsung Galaxy Note 2)和Chrome浏览器中,位置:固定且菜单的实际位置失败,菜单显示在我的网站上。 here's a CSS code. 这是CSS代码。 I've searched for the solution and only answers I got that I need to use 我一直在寻找解决方案,只有得到的答案我需要使用

backface-visibility: hidden; and -webkit-transform:translateZ(0);

I did it, but the problem still remains. 我做到了,但问题仍然存在。 I'm a beginner in making mobile compatibility websites and can't figure out what is causing the problem. 我是制作移动兼容性网站的初学者,不知道是什么原因引起的。 hope for your help. 希望对您有所帮助。

nav {
  background-color:White; 
  padding-right: .25em;
  position: fixed;
  left: -25em;
  top: 0;
  padding-top: 3em;
  box-sizing: border-box;
  z-index: 300;
  height: 100%;
  -webkit-transition: all .5s ease-in-out;
  -o-transition: all .5s ease-in-out;
  transition: all .5s ease-in-out;
  -webkit-backface-visibility: hidden;
  -webkit-transform:translateZ(0);
  backface-visibility: hidden;
}

nav.active 
{
left: 0;
overflow:auto;
}

    <script type="text/javascript">
//jquery for switching the class
 $('#mobile-sidebar').click(function (event) {
      $('nav').toggleClass('active');
 });
</script>

PS Sry for my bad english. PS对不起,我的英语不好。

You can used @media rule, is used to define different style rules for different media types/devices. 您可以使用@media规则,用于为不同的媒体类型/设备定义不同的样式规则。

@media screen and (min-width: 480px) {
    nav {
  background-color:White; 
  padding-right: .25em;
  position: fixed;
  left: -25em;
  top: 0;
  padding-top: 3em;
  box-sizing: border-box;
  z-index: 300;
  height: 100%;
  -webkit-transition: all .5s ease-in-out;
  -o-transition: all .5s ease-in-out;
  transition: all .5s ease-in-out;
  -webkit-backface-visibility: hidden;
  -webkit-transform:translateZ(0);
  backface-visibility: hidden;
}

nav.active 
{
left: 0;
overflow:auto;
}

}

Check min-width for Samsung Galaxy Note 2. try to used @media rules for mobile compatibility and change css as per devices(width). 检查Samsung Galaxy Note 2的最小宽度。尝试使用@media规则以实现移动兼容性,并根据设备(宽度)更改css。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM