巨型菜单显示div悬停

时间:2017-08-09 14:34:18

标签: css hover megamenu

我正在尝试为大型菜单添加效果。 (它位于健康标签下)当您将鼠标悬停在左侧的链接上时,应该会出现右侧的部分。看看其他堆栈溢出示例我发现如果我使用:hover + div来进行div显示,那应该可行,但由于某种原因它不是。一些帮助将不胜感激!

@import url("http://fonts.googleapis.com/css?family=Roboto");
/* mini reset */
.nav,
.nav a,
.nav ul,
.nav li,
.nav div,
.nav form,
.nav input {
	border: none;
	margin: 0;
	outline: none;
	padding: 0;
}
.nav a {
  text-decoration: none;
}
.nav li {
  list-style: none;
}

/* menu container */
.nav,
input {
  font-family: "Roboto", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
}
.nav {
	cursor: default;
	display: inline-block;
	position: relative;
	z-index: 500;
}

/* menu list */
.nav > li {
	display: block;
	float: left;
}

/* menu links */
.nav > li > a {
  background: #0a64a2;
  border-left: 1px solid #0f8ee2 !important;
  display: block;
  color: #fcfcfc;
  font-weight: bold;
  height: 54px;
  line-height: 54px;
  padding: 0 20px;
  position: relative;
  text-shadow: 0 0 1px rgba(0,0,0,.35);
  -webkit-transition: all .3s ease;
  transition: all .3s ease;
  z-index: 510;
}
.nav > li:hover > a {
  background: #8cbd3a;
}
.nav > li:first-child > a {
  border-left: none;
  border-radius: 3px 0 0 3px;
}

/* search form */
.nav > li.nav-search > form {
  border-left: 1px solid #0f8ee2;
  height: 54px;
  position: relative;
  width: inherit;
  z-index: 510;
}
.nav > li.nav-search input[type="text"] {
  background: #0a64a2;
  display: block;
  font-weight: bold;
  font-size: 14px;
  float: left;
  height: 54px;
  line-height: 24px;
  padding: 15px 0 !important;
  text-shadow: 0 0 1px rgba(0,0,0,.35);
  -webkit-transition: all .3s ease 1s;
  transition: all .3s ease 1s;
  width: 1px;
  color: #ebebeb;
}
.nav > li.nav-search input[type="text"]:focus {
  color: #fcfcfc;
  border:none;
  box-shadow: none;
}
.nav > li.nav-search input[type="text"]:focus,
.nav > li.nav-search:hover input[type="text"] {
  padding: 15px 20px !important;
  -webkit-transition: all .3s ease .1s;
  transition: all .3s ease .1s;
  min-width: 110px;
  width: 60%;
  color: #ebebeb;
}
.nav > li.nav-search input[type="submit"] {
	background: #0a64a2 url(../img/search-icon.png) no-repeat center center;
	border-radius: 0 3px 3px 0;
	cursor: pointer;
	display: block;
	float: left;
	height: 54px;
	padding: 0 25px;
	-webkit-transition: all .3s ease;
	transition: all .3s ease;
	width: 20px;
}
.nav > li.nav-search input[type="submit"]:hover {
  background-color: #4b4441;
}

/* menu dropdown */
.nav > li > div {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 0 0 3px 3px;
  position: absolute;
  display: block;
  left: 0;
  opacity: 0;
  overflow: hidden;
  top: 50px;
  -webkit-transition: all .3s ease .15s;
	transition: all .3s ease .15s;
	visibility: hidden;
	width: 100%;
}
.nav > li:hover > div {
	opacity: 1;
	overflow: visible;
	visibility: visible;
}

/* menu content styles */
.nav .nav-column {
	float: left;
	padding: 2.5%;
	width: 25%;
}
.nav .nav-column h3 {
	color: #372f2b;
	font-size: 14px;
	font-weight: bold;
	line-height: 18px;
	margin: 20px 0 10px 0;
	text-transform: uppercase;
}
.nav .nav-column h3.orange {
  color: #ff722b;
}
.nav .nav-column li a {
	color: #888;
	display: block;
	font-weight: bold;
	line-height: 26px;
}
.nav .nav-column li a:hover {
  color: #8cbd34;
}

.nav a:hover > .menuheader {
	color: #8cbd3a;
}
.nav a p {
	color: black;
	font-weight: normal;
}
.menuheader {
	font-weight: bold !important;
	margin-bottom: 0px;
	margin-top: 5px;
	font-size: 1.2em;
	line-height: 18px;
}

.nav-column.info {
	width: 75%;
}
.nav-column.info a {
	display: none !important;
}
.healthlink1:hover + .healthinfo1 {
	display: block !important;
}
<link href="https://dhbhdrzi4tiry.cloudfront.net/cdn/sites/foundation.min.css" rel="stylesheet"/>
<div class="menu-wrapper">
      <ul class="nav">
        <li><a href="#">item</a></li>
        <li><a href="#">item</a></li>
        <li><a href="#">Health</a>
          <div>
            <div class="nav-column left">
              <ul>
                <li class="healthlinks">
                  <a href="#" class="healthlink1">Asthma</a>
                  <a href="#" class="healthlink2">Birth Defects</a>
                  <a href="#">Cancer</a>
                  <a href="#">Carbon Monoxide Poisoning</a>
                  <a href="#">COPD</a>
                  <a href="#">Heart Attacks</a>
                  <a href="#">Heat Related Illness</a>
                  <a href="#">Lead Poisoning</a>
                  <a href="#">Oral Health</a>
                  <a href="#">Reproductive Outcomes</a>
                </li>
              </ul>
            </div><!-- /nav-column -->
            <div class="nav-column info left">
              <ul>
                <li>
                  <a href="#" class="healthinfo1">Asthma info</a>
                  <a href="#" class="healthinfo2">Birth Defects info</a>
                  <a href="#">Cancer info</a>
                  <a href="#">Carbon Monoxide Poisoning info</a>
                  <a href="#">COPD info</a>
                  <a href="#">Heart Attacks info</a>
                  <a href="#">Heat Related Illness info</a>
                  <a href="#">Lead Poisoning info</a>
                  <a href="#">Oral Health info</a>
                  <a href="#">Reproductive Outcomes info</a>
                </li>
              </ul>
            </div><!-- /nav-column -->
          </div>
        </li>
        <li><a href="#">item</a></li>
        <li><a href="#">item</a></li>
        <li><a href="#">item</a></li>
       </ul>
</div>

2 个答案:

答案 0 :(得分:0)

.nav-column.info a {
    display: none !important;
}

display:none!important;

的问题

只需将其从css样式中删除,即可显示右边的div。

https://jsfiddle.net/cyhog5ra/

答案 1 :(得分:0)

好的,所以我找到了基础6,它完全符合我的需要,以帮助其他有问题的人在这里工作!`

&#13;
&#13;
$(document).ready(function() {
  $(document).foundation();
})
&#13;
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/vendor/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/js/foundation.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/css/foundation.css">
<div class = "row collapse">
   <div class = "medium-3 columns">
      <ul class = "tabs vertical" data-tabs id = "tabs_example">
      <li class = "tabs-title is-active"><a href = "#tab1">text 1</a></li>
      <li class = "tabs-title"><a href = "#tab2">text 2</a></li>
      <li class = "tabs-title"><a href = "#tab3">text 3</a></li>
      <li class = "tabs-title"><a href = "#tab4">text 4</a></li>
      <li class = "tabs-title"><a href = "#tab5">text 5</a></li>
   </ul>
</div>

<div class = "medium-9 columns">
   <div class = "tabs-content vertical" data-tabs-content = "tabs_example">
      <div class = "tabs-panel is-active" id = "tab1">
         <p>First text</p>
      </div>

      <div class = "tabs-panel" id = "tab2">
         <p>Second text</p>
      </div>
      
      <div class = "tabs-panel" id = "tab3">
         <p>Third text</p>
      </div>

      <div class = "tabs-panel" id = "tab4">
         <p>Fourth text</p>
      </div>
      
      <div class = "tabs-panel" id = "tab5">
         <p>Five text</p>
      </div>
   </div>
</div>
&#13;
&#13;
&#13;

`