robbiejobs
robbiejobs

Reputation: 45

Make submenu dropdown wider than parent li

I did the job by make the submenu functioning, the problem is I can't get the submenu width wider than its parent.

when i hover, its messed up as you can see in fiddle links i provided below

please take a look at this http://jsfiddle.net/wR5L5/

    .navigation {
  height: 35px;
  background: #333;
}
.navigation ul {
  margin: 0;
  padding: 0;
}
.navigation ul li {
  position: relative;
  display: inline;
}
.navigation ul li a {
  text-transform: uppercase;
  color: #fff;
  font-weight: 700;
  line-height: 35px;
  padding: 6px 8px;
  text-shadow: 0px 0px 1px #ff170f;
}
.navigation ul li a:hover {
  text-decoration: none;
  color: #FF3E36;
  border-bottom: 2px solid #FF3E36;
}
.navigation ul li:hover ul {
  left: 0;
}
.navigation ul .sub {
  position: absolute;
  z-index: 9999;
  left: -9999px;
  font-size: 13px;
}
.navigation ul .sub li {
  padding-top: -4px;
  float: none;
  background: #fff;
}
.navigation ul .sub li a {
  text-shadow: none;
  color: #333;
}
.navigation ul .sub li a:hover {
  color: #ff3e36;
  border-bottom: none;
  text-shadow: none;
}
.navigation ul .sub li:hover {
  background: #333;
}

Upvotes: 1

Views: 9338

Answers (2)

Hushme
Hushme

Reputation: 3144

there is a flexible menu .sub class http://jsfiddle.net/wR5L5/12/

.navigation {
  height: 35px;
  background: #333;
}

.navigation ul {
  margin: 0;
  position: relative;
  padding: 0;
}

.navigation ul li {
  display: inline;
  position: relative;
}

.navigation ul li a {
  text-transform: uppercase;
  color: #fff;
  font-weight: 700;
  line-height: 35px;
  padding: 6px 8px;
  text-shadow: 0px 0px 1px #ff170f;
}

.navigation ul li a:hover {
  text-decoration: none;
  color: #FF3E36;
  border-bottom: 2px solid #FF3E36;
}

.navigation ul li:hover ul {
  left: 0;
}

.navigation ul .sub {
  position: absolute;
  z-index: 9999;
  left: -9999px;
  float: left;
  width: auto;
  min-width: 100%;
  background: #999;
  font-size: 13px;
}

.navigation ul .sub li {
  padding-top: -4px;
  float: none;
  white-space: nowrap;
  clear: both;
  background: #fff;
}

.navigation ul .sub li a {
  text-shadow: none;
  color: #333;
  display: block;
  float: none;
  width: 100%;
}

.navigation ul .sub li a:hover {
  color: #ff3e36;
  border-bottom: none;
  text-shadow: none;
}

.navigation ul .sub li:hover {
  background: #333;
}

Upvotes: 3

web2008
web2008

Reputation: 914

Give width to the sub menu to get submenu wider than main menu.

.navigation ul .sub {
  position: absolute;
  z-index: 9999;
  left: -9999px;
  width: 150px;
  font-size: 13px;
}

Upvotes: 1

Related Questions