最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Removing "bullets" from <ul> in CSS navigation menu - Stack Overflow

programmeradmin1浏览0评论

Hi I'm using a CSS menu navigation for a client however the menu shows 'bullets' - I've seen other people suggest to use list-style: none; and I tried adding that to every element in this CSS stylesheet to no avail. The client would like to either remove the bullets pletely or change their color. So far I have been unsuccessful in removing the bullets.

See the sample website here

Does anyone have a modification to 'styles.css' below that we could use to modify the css menu so you don't see the bullets?

@import url(+Sans);

#cssmenu {
  background: none;
  width: auto;
  margin-top:-15px;

}
#cssmenu ul {
  list-style: none;
  margin: 0;
  padding: 0;
  line-height: 1;
  display: block;
  zoom: 1;
}
#cssmenu ul:after {
  content: " ";
  display: block;
  font-size: 0;
  height: 0;
  clear: both;
  visibility: hidden;
  list-style: none;
}
#cssmenu ul li {
  display: inline-block;
  padding: 0;
  margin: 0;
  list-style: none;
}
#cssmenu.align-right ul li {
  float: right;
}
#cssmenu.align-center ul {
  text-align: center;
}
#cssmenu ul li a {
  list-style: none;
  color: #d6d6da;
  text-decoration: none;
  display: block;
  padding: 15px 20px;
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 50;
  font-size: 13px;
  position: relative;
  letter-spacing: .5px;
  -webkit-transition: color .25s;
  -moz-transition: color .25s;
  -ms-transition: color .25s;
  -o-transition: color .25s;
  transition: color .25s;
}
#cssmenu ul li a:hover {
  color: #ff893f;
}
#cssmenu ul li a:hover:before {
  width: 100%;
}
#cssmenu ul li a:after {
  content: "";
  display: block;
  position: absolute;
  right: -3px;
  top: 19px;
  height: 6px;
  width: 6px;
  background: #ffffff;
  opacity: .5;
  list-style: none;
}
#cssmenu ul li a:before {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0;
  background: #333333;
  -webkit-transition: width .25s;
  -moz-transition: width .25s;
  -ms-transition: width .25s;
  -o-transition: width .25s;
  transition: width .25s;
}
#cssmenu ul li.last > a:after,
#cssmenu ul li:last-child > a:after {
  display: none;
}
#cssmenu ul li.active a {
  color: #0076c0;
}
#cssmenu ul li.active a:before {
  width: 100%;
}
#cssmenu.align-right li.last > a:after,
#cssmenu.align-right li:last-child > a:after {
  display: block;
}
#cssmenu.align-right li:first-child a:after {
  display: none;
}
@media screen and (max-width: 768px) {
  #cssmenu ul li {
    float: none;
    display: block;
  }
  #cssmenu ul li a {
    width: 100%;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    border-bottom: 1px solid #000000;
    list-style: none;
  }
  #cssmenu ul li.last > a,
  #cssmenu ul li:last-child > a {
    border: 0;
  }
  #cssmenu ul li a:after {
    display: none;
  }
  #cssmenu ul li a:before {
    display: none;
  }
}

Hi I'm using a CSS menu navigation for a client however the menu shows 'bullets' - I've seen other people suggest to use list-style: none; and I tried adding that to every element in this CSS stylesheet to no avail. The client would like to either remove the bullets pletely or change their color. So far I have been unsuccessful in removing the bullets.

See the sample website here

Does anyone have a modification to 'styles.css' below that we could use to modify the css menu so you don't see the bullets?

@import url(http://fonts.googleapis./css?family=Josefin+Sans);

#cssmenu {
  background: none;
  width: auto;
  margin-top:-15px;

}
#cssmenu ul {
  list-style: none;
  margin: 0;
  padding: 0;
  line-height: 1;
  display: block;
  zoom: 1;
}
#cssmenu ul:after {
  content: " ";
  display: block;
  font-size: 0;
  height: 0;
  clear: both;
  visibility: hidden;
  list-style: none;
}
#cssmenu ul li {
  display: inline-block;
  padding: 0;
  margin: 0;
  list-style: none;
}
#cssmenu.align-right ul li {
  float: right;
}
#cssmenu.align-center ul {
  text-align: center;
}
#cssmenu ul li a {
  list-style: none;
  color: #d6d6da;
  text-decoration: none;
  display: block;
  padding: 15px 20px;
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 50;
  font-size: 13px;
  position: relative;
  letter-spacing: .5px;
  -webkit-transition: color .25s;
  -moz-transition: color .25s;
  -ms-transition: color .25s;
  -o-transition: color .25s;
  transition: color .25s;
}
#cssmenu ul li a:hover {
  color: #ff893f;
}
#cssmenu ul li a:hover:before {
  width: 100%;
}
#cssmenu ul li a:after {
  content: "";
  display: block;
  position: absolute;
  right: -3px;
  top: 19px;
  height: 6px;
  width: 6px;
  background: #ffffff;
  opacity: .5;
  list-style: none;
}
#cssmenu ul li a:before {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0;
  background: #333333;
  -webkit-transition: width .25s;
  -moz-transition: width .25s;
  -ms-transition: width .25s;
  -o-transition: width .25s;
  transition: width .25s;
}
#cssmenu ul li.last > a:after,
#cssmenu ul li:last-child > a:after {
  display: none;
}
#cssmenu ul li.active a {
  color: #0076c0;
}
#cssmenu ul li.active a:before {
  width: 100%;
}
#cssmenu.align-right li.last > a:after,
#cssmenu.align-right li:last-child > a:after {
  display: block;
}
#cssmenu.align-right li:first-child a:after {
  display: none;
}
@media screen and (max-width: 768px) {
  #cssmenu ul li {
    float: none;
    display: block;
  }
  #cssmenu ul li a {
    width: 100%;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    border-bottom: 1px solid #000000;
    list-style: none;
  }
  #cssmenu ul li.last > a,
  #cssmenu ul li:last-child > a {
    border: 0;
  }
  #cssmenu ul li a:after {
    display: none;
  }
  #cssmenu ul li a:before {
    display: none;
  }
}
Share Improve this question asked Nov 18, 2014 at 22:02 ViktorViktor 5477 silver badges24 bronze badges 3
  • 2 just set a list-style: none – Mike 'Pomax' Kamermans Commented Nov 18, 2014 at 22:06
  • 1 Applying list-style: none to your <ul> element should work (see this example). If it doesn't, it means there is either a) a typo in your CSS or the more likely b) some other CSS has a more specific selector and is overriding your selections. Open your browser's dev tools by selecting <F12> and view the CSS being applied to the element. – War10ck Commented Nov 18, 2014 at 22:06
  • 1 those are not the default list bullets those are styled pseudo elements from the styles.css file you are looking for #cssmenu ul li a:after { remove that rule – Patrick Evans Commented Nov 18, 2014 at 22:06
Add a ment  | 

2 Answers 2

Reset to default 8

You need to remove the following rule:

#cssmenu ul li a:after {
    content: "";
    display: block;
    position: absolute;
    right: -3px;
    top: 19px;
    height: 6px;
    width: 6px;
    background: none repeat scroll 0% 0% #FFF;
    opacity: 0.5;
    list-style: outside none none;
}

I see that the html code for division -cssmenu is declared as 'id'. you should probably use div#cssmenu in your stylesheet.

just add a predecessor div to #cssmenu it should work.

Note: i have inline style declaration.

Sample:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3/1999/xhtml">
<head>
<style>
div#cssmenu {
  background: none;
  width: auto;
  margin-top:-15px;
}
div#cssmenu ul {
  list-style: none;
  margin: 0;
  padding: 0;
  line-height: 1;
  display: block;
}
div#cssmenu ul:after {
  content: " ";
  display: block;
  font-size: 0;
  height: 0;
  clear: both;
  visibility: hidden;
  list-style: none;
}
div#cssmenu ul li {
  display: inline-block;
  padding: 0;
  margin: 0;
  list-style: none;
}
div#cssmenu.align-right ul li {
  float: right;
}
div#cssmenu.align-center ul {
  text-align: center;
}
div#cssmenu ul li a {
  list-style: none;
  color: #d6d6da;
  text-decoration: none;
  display: block;
  padding: 15px 20px;
  font-family: 'Josefin Sans', sans-serif;
  font-weight: 500;
  font-size: 13px;
  position: relative;
  letter-spacing: .5px;
  -webkit-transition: color .25s;
  -moz-transition: color .25s;
  -ms-transition: color .25s;
  -o-transition: color .25s;
  transition: color .25s;
}
div#cssmenu ul li a:hover {
  color: #ff893f;
}
div#cssmenu ul li a:hover:before {
  width: 100%;
}
div#cssmenu ul li a:after {
  content: "";
  display: block;
  position: absolute;
  right: -3px;
  top: 19px;
  height: 6px;
  width: 6px;
  background: #ffffff;
  opacity: .5;
  list-style: none;
}
div#cssmenu ul li a:before {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0;
  background: #333333;
  -webkit-transition: width .25s;
  -moz-transition: width .25s;
  -ms-transition: width .25s;
  -o-transition: width .25s;
  transition: width .25s;
}
div#cssmenu ul li.last > a:after,
div#cssmenu ul li:last-child > a:after {
  display: none;
}
div#cssmenu ul li.active a {
  color: #0076c0;
}
div#cssmenu ul li.active a:before {
  width: 100%;
}
div#cssmenu.align-right li.last > a:after,
div#cssmenu.align-right li:last-child > a:after {
  display: block;
}
div#cssmenu.align-right li:first-child a:after {
  display: none;
}

  div#cssmenu ul li a {
    width: 100%;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    border-bottom: 1px solid #000000;
    list-style: none;
  }
  div#cssmenu ul li.last > a,
  div#cssmenu ul li:last-child > a {
    border: 0;
  }
  div#cssmenu ul li a:after {
    display: none;
  }
  div#cssmenu ul li a:before {
    display: none;
  }
</style>
</head>
<body>

<div id='cssmenu'>
<ul>
   <li><a href='#'><span>Home</span></a></li>
   <li><a href='#'><span>About Us</span></a></li>
   <li><a href='#'><span>Decorative</span></a></li>
   <li><a href='#'><span>Lighting</span></a></li>
   <li><a href='#'><span>Mirrors</span></a></li>
   <li><a href='#'><span>Rugs/Textiles</span></a></li>
   <li><a href='#'><span>Architectural</span></a></li>
   <li><a href='#'><span>Garden</span></a></li>
   <li><a href='#'><span>Recycled</span></a></li>
   <li class='last'><a href='#'><span>Contact</span></a></li>
</ul>
</div>
</body>
</html>
发布评论

评论列表(0)

  1. 暂无评论