热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

固定位置侧边栏和靠近它的下拉菜单-Fixedpositionsidebaranddropdownmenunearit

Hereismycode这是我的代码html<nav><ul><li><ahref#>Link

Here is my code

这是我的代码

html


css

html,
  body {
  padding: 0;
  margin: 0;
  height: 100%;
}

nav {
  width: 300px;
  box-sizing:border-box;
  padding:20px 0;
  height: 100%;
  background: #000;
  position: fixed;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

li {
  padding: 0;
  margin: 0;
}

.main li a {
  color: #fff;
  display: block;
  padding: 8px 20px;
}

.main li:hover {
  background: red
}

.main ul {
  display: none;
}

nav:hover {
  overflow: auto;
  background: #000;
  z-index: 1000;
}

.main li:hover ul {
  top: 0;
  padding:20px 0;
  box-sizing:border-box;
  height:100%;
  display: block;
  position: fixed;
  left: 270px;
  width: 200px;
  overflow: auto;
  bottom: 0px;
  z-index: 99;
  background:#333;
}

.content {
  margin-left: 350px;
  font-size: 30px;
}

The problem is that when you hover on Hover Me 1 you need see dropdown menu near sidebar. On windows its working fine, but in iOS and OsX its dont work! I dont know how to get rid of this problem.. May be is there any solution preferably on CSS, but if not - I am ready for jQuery.. Please tell me something, I already have a headache from this problem :(

问题是当你将鼠标悬停在Hover Me 1上时,你需要看到侧边栏附近的下拉菜单。在Windows上它工作正常,但在iOS和OsX它不工作!我不知道如何摆脱这个问题..可能是有任何解决方案最好在CSS,但如果没有 - 我准备jQuery ..请告诉我一些事情,我已经从这个问题头痛:(

Here is JsFiddle DEMO

这是JsFiddle DEMO

2 个解决方案

#1


0  

You will want to use position absolute on the sub menu and position relative on the parent li, something like this:

您将需要在子菜单上使用position absolute并在parent li上使用相对位置,如下所示:

.main > li {
position:relative;
}
.main li:hover ul {
position: absolute;
left:300px;
top:0;
}

#2


0  

You need to make your code responsive and you can do this by adding media tag in your css for different screen size ios screen size then modify your code according to ios screen size like this mockup enter image description here see this DEMO

您需要使您的代码响应,您可以通过在您的CSS中添加媒体标签来实现这一目标,以适应不同的屏幕尺寸ios屏幕大小,然后根据ios屏幕大小修改您的代码,就像这个模型一样看这个DEMO


推荐阅读
author-avatar
enbel2012_707
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有