简体   繁体   English

使用多个无序(UL)列表和列表项CSS / HTML

[英]Using Multiple Unordered(UL) Lists and List ItemsCSS/HTML

I have two separate working 'objects' 我有两个单独的工作“对象”

A menu bar, working entirely in CSS. 菜单栏,完全在CSS中工作。 See it working here: http://jsbin.com/EMEraZu/1/edit?html,css,js,output 看到它在这里工作: http : //jsbin.com/EMEraZu/1/edit?html,css,js,output

And I have a fancy CSS/Java slideshow here: http://jsbin.com/ijUW/1/edit?html,css,js,output 而且我在这里有一个精美的CSS / Java幻灯片: http : //jsbin.com/ijUW/1/edit?html, css, js,output

These work perfectly until I try to combine them together on one page, where upon the CSS mucks up.Now, every thumbnail on the slideshow is a list item (li) element, in my novice opinion, this is conflicting with the UL and LI elements in the menu bar. 直到我尝试将它们组合到一页,然后CSS变得混乱为止,这些功能才能正常工作。现在,幻灯片放映中的每个缩略图都是一个列表项(li)元素,在我看来,这与UL和LI冲突菜单栏中的元素。 Is this the problem? 这是问题吗? I tried fixing it by creating a div tag for the menubar. 我尝试通过为菜单栏创建div标签来修复它。 But I've had no luck. 但是我没有运气。 Any suggestions? 有什么建议么?

I've copied the CSS and HTML below 我已经在下面复制了CSS和HTML

 #menubar ul {
  text-align: left;
  display: inline;
  margin: 0;
  padding: 15px 4px 17px 0;
  list-style: none;
  -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
  -moz-box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.15);
}
#menubar ul li {
  font: 18px;
  font-family: latolight;
  display: inline-block;
  margin-right: -4px;
  position: relative;
  padding: 15px 20px;
  background: #fff;
  cursor: pointer;
  -webkit-transition: all 0.2s;
  -moz-transition: all 0.2s;
  -ms-transition: all 0.2s;
  -o-transition: all 0.2s;
  transition: all 0.2s;
}
#menubar ul li:hover {
    background: #555;
    color: #fff;
    font-family: latolight;
}
#menubar ul li ul {
  padding: 0;
  position: absolute;
  top: 43px;
  left: 0;
  width: 150px;
  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  box-shadow: none;
  display: none;
  opacity: 0;
  visibility: hidden;
  -webkit-transiton: opacity 0.2s;
  -moz-transition: opacity 0.2s;
  -ms-transition: opacity 0.2s;
  -o-transition: opacity 0.2s;
  -transition: opacity 0.2s;
}
#menubar ul li ul li { 
  background: #555; 
  display: block; 
  color: #fff;
  text-shadow: 0 -1px 0 #000;
}
#menubar ul li ul li:hover { background: #666; }

#menubar ul li:hover ul {
  display: block;
  opacity: 1;
  visibility: visible;
}

<div id="menubar">
<ul>
  <li>Home</li>
  <li>Title
  <ul>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
    </ul></li>
  <li>
    Title2
    <ul>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
    </ul>
  </li>
</ul>
</div>

//* Above was Menubar code, it somehow conflicts with the gallery code, below, // *上面是菜单栏代码,它与下面的图库代码有些冲突,

#gallery{

    /* CSS3 Box Shadow */
    -moz-box-shadow:0 0 3px #AAAAAA;
    -webkit-box-shadow:0 0 3px #AAAAAA;
    box-shadow:0 0 3px #AAAAAA;

    /* CSS3 Rounded Corners */

    -moz-border-radius-bottomleft:4px;
    -webkit-border-bottom-left-radius:4px;
    border-bottom-left-radius:4px;

    -moz-border-radius-bottomright:4px;
    -webkit-border-bottom-right-radius:4px;
    border-bottom-right-radius:4px;

    border:1px solid white;

    background:url(img/panel.jpg) repeat-x bottom center #ffffff;

    /* The width */
    width:920px;
    overflow:hidden;
}

#slides{

    height:400px;

    /* jQuery willchange the width later on to the sum of the widths of all the slides. */
    width:920px;
    overflow:hidden;
}

.slide{
    float:left;
}

#menu{
    /* container for the thumbnails */
    height:90px;
}


li{
    /* Every thumbnail is a li element */
    width:120px;
    display:inline-block;
    list-style:none;
    height:90px;
    overflow:hidden;
}

li.inact:hover{
    /* The inactive state, highlighted on mouse over */
    background:url(img/pic_bg.png) repeat;
}

li.act,li.act:hover{
    /* The active state of the thumb */
    background:url(img/active_bg.png) no-repeat;
}

.fbar{
    /* The left-most vertical bar */
    width:2px;
    background:url(img/divider.png) no-repeat right;
}

li a{
    display:block;
    background:url(img/divider.png) no-repeat right;
    height:70px;
    padding-top:10px;
}

a img{
    border:none;
}

<div id="main">




  <div id="gallery">

    <div id="slides">

    <div class="slide"><a href="www.google.com"><img src="img/sample_slides/1.jpg" width="920" height="400" alt="side" /></a></div>
    <div class="slide"><a href="www.google.com"><img src="img/sample_slides/2.jpg" width="920" height="400" alt="side" /></a></div>
    <div class="slide"><a href="www.google.com"><img src="img/sample_slides/3.jpg" width="920" height="400" alt="side" /></a></div>
    <div class="slide"><a href="www.google.com" target="_blank"><img src="img/sample_slides/4.jpg" width="920" height="400" alt="side" /></a></div>

    </div>

    <div id="menu">

    <ul>
        <li class="fbar">&nbsp;</li><li class="menuItem"><a href=""><img src="img/thumb_1.png" alt="thumbnail" width="85" /></a></li><li class="menuItem"><a href=""><img src="img/thumb_2.png" alt="thumbnail" width="85" /></a></li><li class="menuItem"><a href=""><img src="img/thumb_3.png" alt="thumbnail" width="85" /></a></li><li class="menuItem"><a href=""><img src="img/thumb_4.png" alt="thumbnail" width="85" /></a></li>
    </ul>


    </div>

  </div>

</div>
</body>
</html>

Any ideas at all would be appreciated on why they are clashing. 关于它们为什么会冲突的任何想法都将不胜感激。

i think your gallery css needs to be more specific to which elements to style, like you have done with the menu css by adding parents id. 我认为您的图库CSS需要更具体地设置样式元素,就像您通过添加父母ID来使用菜单CSS一样。 as there is no id with gallery css, its going to effect all li elements 因为画廊css没有id,它将影响所有li元素

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

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