jsfiddle:http://jsfiddle.net/dalal/e3BHm/这显示了我在说什么..请检查一下..
我在另一个样式列表中有一个样式列表。我不希望第二个列表继承第一个列表的样式,但确实如此!! 这是我在样式表文件中得到的示例:
.tabs
{
position:relative;
text-align:left; /* This is only if you want the tab items at the center */
width: 90%;
padding: 0;
margin: 0;
/*border: 1px solid green;*/
}
.tabs ul
{
list-style-type:none;
display:block; /* Change this to block or inline for non-center alignment */
width:570px;
/* min-width:570px;
max-width:800px;
vertical-align: bottom;
/*border: 1px solid red;*/
}
.tabs ul ul.mm
{
list-style-type:none;
display:block; /* Change this to block or inline for non-center alignment */
/* min-width:570px;
max-width:800px;
vertical-align: bottom;
/*border: 1px solid red;*/
}
.tabs ul li
{
display:inline;
float:center;
vertical-align: bottom;
/** border: 1px solid yellow;*/
cursor:hand;
}
.tabs ul ul.mm li.oo
{
display:block;
float:center;
vertical-align: bottom;
/** border: 1px solid yellow;*/
cursor:hand;
}
.tabs ul li a
{
color:#7a7883;
text-decoration:none;
display:inline-block;
text-align:center;
border:1px solid #f1f3f4;
padding:5px 10px 5px 10px;
width: 25%;
font-size:15px;
font-family:"Times New Roman", Times, serif;
border-top-left-radius:5px; -moz-border-radius-topleft:4px; -webkit-border-top-left-radius:5px;
border-top-right-radius:5px; -moz-border-radius-topright:4px; -webkit-border-top-right-radius:5px;
-moz-user-select:none;
cursor:hand;
/* Safari 4-5, Chrome 1-9 */ background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#fff), to(#aeb8c0));
/* Safari 5.1, Chrome 10+ */ background: -webkit-linear-gradient(top, #aeb8c0, #fff); /* Firefox 3.6+ */ background: -moz-linear-gradient(top, #aeb8c0, #fff);
/* IE 10 */ background: -ms-linear-gradient(top, #aeb8c0, #fff); /* Opera 11.10+ */ background: -o-linear-gradient(top, #aeb8c0, #fff);
}
.tabs ul ul.mm li.oo a
{
color:red;
text-decoration:none;
display:inline-block;
text-align:center;
padding:5px 10px 5px 10px;
width: 25%;
font-size:15px;
font-family:"Times New Roman", Times, serif;
}
.tabs ul li a:hover
{
color: #fff;
cursor:hand;
}
.tabs ul li div
{
display:none;
position:absolute;
width:98%;
/* max-width:700px;*/
min-height:230px;
left:0;
margin: 0 15px 0 15px;
z-index:-1;
text-align:left;
padding:0;
}
.tabs ul li div p
{
border:1px solid #f1f3f4;
background-color: #f5f9fc;
width: 99%;
padding:10px;
margin:0;
color: #65636e;
font-size:12px;
font-family:"Times New Roman", Times, serif;
text-decoration: none;
min-height:200px;
}
.tabs ul li a:focus
{
color: #f5f9fc;
}
.tabs ul li:target a
{
cursor:default;
/* Safari 4-5, Chrome 1-9 */
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#f1f3f4), to(#fff));
/* Safari 5.1, Chrome 10+ */
background: -webkit-linear-gradient(top, #fff, #f1f3f4);
/* Firefox 3.6+ */
background: -moz-linear-gradient(top, #fff, #f1f3f4);
/* IE 10 */
background: -ms-linear-gradient(top, #fff, #f1f3f4);
/* Opera 11.10+ */
background: -o-linear-gradient(top, #fff, #f1f3f4);
cursor:hand;
}
.tabs ul li:target div
{
display:block;
}
这是页面内的代码:
<div class="t" >
<ul class="menu">
<li id="item-1" >
<a href="#item-1">First Main List</a>
<div style="display:block" class="myList" id="#item-1">
<p>
<ul class="m">
<li><a href="">second list</a></li>
<li><a href="">second list</a></li>
<li><a href="">second list</a></li>
<li><a href="">second list</a></li>
</ul>
</p>
</div>
</li>
<li id="item-2"> .......
</li>
我面临的问题是第二个列表没有出现在我为他们制作的样式中。另外,第二个列表显示在 <p>
block 之后。不在里面。
提前谢谢你:)
最佳答案
您忘记了 CSS 第 17 行和第 39 行的 >
...
就像这样:
.t ul.menu li > a
实际上应该是 .t ul.menu > li > a
。
另请注意,您为第一个列表和第二个列表选择了相同的颜色。#7a7883
。只是为了测试——我注释掉了第二个列表的颜色,你看它不继承
检查这个:jsFiddle
关于html - 在另一个样式的 ul 中样式化 ul,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17287139/