这段时间我已经浏览过这个网站很多次了。它对很多事情都很有帮助。所以谢谢你们!
我有一个问题,我不能设法解决。我已经深入研究了其他职位在这里stackoverflow(真的),但即使我得到的信息是安静的清晰和解决方案似乎直截了当,我不能得到这个工作,对不起。
基本上,我有一个WordPress网站,我创建了一个主菜单导航栏。元素是通过使用<?php wp_list_pages('title_li='); ?>
显示,然后与CSS我已经样式化的所有元素,以显示元素之间的垂直分隔符。
问题是我不能让最后一项与其他项不同(我不希望它显示垂直分隔符,因为它是最后一个)我已经尝试了许多选项,按照您的善意建议,但没有工作,所以我没有删除所有失败的尝试代码。
任何帮助都将不胜感激。
下面是我的代码:
<div id="cssmenu">
<ul class="nav" id="primary-nav">
<?php if (is_page()) { $highlight = "page_item"; } else {$highlight = "page_item current_page_item"; } ?>
<li class="<?php echo $highlight; ?>"><a href="<?php bloginfo('url'); ?>">WELCOME</a></li>
<?php wp_list_pages('title_li='); ?>
</ul>
</div>
CSS可以在这里找到:
#cssmenu {
height:37px;
display:block;
padding:0;
margin:0 auto;
border: 1px solid #444758;
border-bottom: 1px solid #bbbdc5;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 20px 20px rgba(255, 255, 255, 0.12), 0 1px 1px #9c9c9c, inset 0 -1px 0 #343746;
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 20px 20px rgba(255, 255, 255, 0.12), 0 1px 1px #9c9c9c, inset 0 -1px 0 #343746;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 20px 20px rgba(255, 255, 255, 0.14), inset 0 -1px 0 #343746;
}
#cssmenu > ul {list-style:inside none; padding:0; margin:0;}
#cssmenu > ul > li {list-style:inside none; padding:0; margin:0; float:left; display:block; position:relative;}
#cssmenu > ul > li > a{ outline:none; display:block; position:relative; padding:9px 37px; font-size: 15px; letter-spacing: 0; text-align:center; text-decoration:none; text-shadow:0 -1px 0 #000 !important; text-transform: uppercase; }
#cssmenu > ul > li.last-item > a{ padding-right:34px; }
#cssmenu > ul > li:first-child > a{border-radius:4px 0 0 4px;}
#cssmenu > ul > li > a:after{ content:''; position:absolute; border-right:1px solid; top:0; bottom:0; right:-2px; z-index:99; }
#cssmenu > ul > li.last-item > a:after{ border:none; }
#cssmenu ul li.has-sub:hover > a:after{top:0; bottom:0;}
#cssmenu > ul > li.has-sub > a:before{ content:''; position:absolute; top:18px; right:6px; border:4px solid transparent; border-top:4px solid #fff; }
#cssmenu > ul > li.has-sub:hover > a:before{top:19px;}
#cssmenu ul li.has-sub:hover > a{ background:#3f3f3f; border-color:#3f3f3f; padding-bottom:13px; padding-top:13px; top:-1px; z-index:999; }
#cssmenu ul li.has-sub:hover > ul, #cssmenu ul li.has-sub:hover > div{display:block;}
#cssmenu ul li.has-sub > a:hover{background:#3f3f3f; border-color:#3f3f3f;}
#cssmenu ul li > ul, #cssmenu ul li > div{ display:none; width:auto; position:absolute; top:38px; padding:10px 0; background:#3f3f3f; border-radius:0 0 4px 4px; z-index:999; }
#cssmenu ul li > ul{width:200px;}
#cssmenu ul li > ul li{display:block; list-style:inside none; padding:0; margin:0; position:relative;}
#cssmenu ul li > ul li a{ outline:none; display:block; position:relative; margin:0; padding:8px 20px; font:10pt Arial, Helvetica, sans-serif; color:#fff; text-decoration:none; text-shadow:1px 1px 0 rgba(0,0,0, 0.5); }
#cssmenu, #cssmenu > ul > li > ul > li a:hover {
background: #3e4151;
background-repeat: repeat-x;
background-image: -khtml-gradient(linear, left top, left bottom, from(#838796), to(#3e4151));
background-image: -moz-linear-gradient(top, #838796, #3e4151);
background-image: -ms-linear-gradient(top, #838796, #3e4151);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #838796), color-stop(100%, #3e4151));
background-image: -webkit-linear-gradient(top, #838796, #3e4151);
background-image: -o-linear-gradient(top, #838796, #3e4151);
background-image: linear-gradient(top, #838796, #3e4151);
filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#838796', endColorstr='#3e4151',GradientType=0 );
}
#cssmenu{border-color:#353749;}
#cssmenu > ul > li > a{border-right:1px solid #4e5262; color:#fff !important;}
#cssmenu > ul > li > a.last-item{border:none;}
#cssmenu > ul > li > a:after{border-color:#a6a9b4;}
#cssmenu > ul > li > a:hover {
background: #2666c3;
background-repeat: repeat-x;
background-image: -khtml-gradient(linear, left top, left bottom, from(#1c356b), to(#2666c3));
background-image: -moz-linear-gradient(top, #1c356b, #2666c3);
background-image: -ms-linear-gradient(top, #1c356b, #2666c3);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #1c356b), color-stop(100%, #2666c3));
background-image: -webkit-linear-gradient(top, #1c356b, #2666c3);
background-image: -o-linear-gradient(top, #1c356b, #2666c3);
background-image: linear-gradient(top, #1c356b, #2666c3);
filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#1c356b', endColorstr='#2666c3',GradientType=0 );
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 20px 20px rgba(255, 255, 255, 0.12), 0 1px 1px #9c9c9c, inset 0 -1px 0 #343746;
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 20px 20px rgba(255, 255, 255, 0.12), 0 1px 1px #9c9c9c, inset 0 -1px 0 #343746;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 20px 20px rgba(255, 255, 255, 0.14), inset 0 -1px 0 #343746;
}
#cssmenu ul li .current_page_item a,#cssmenu ul li .current_page_item a:hover{
background: #2666c3;
background-repeat: repeat-x;
background-image: -khtml-gradient(linear, left top, left bottom, from(#2666c3), to(#1c356b));
background-image: -moz-linear-gradient(top, #2666c3, #1c356b);
background-image: -ms-linear-gradient(top, #2666c3, #1c356b);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #2666c3), color-stop(100%, #1c356b));
background-image: -webkit-linear-gradient(top, #2666c3, #1c356b);
background-image: -o-linear-gradient(top, #2666c3, #1c356b);
background-image: linear-gradient(top, #2666c3, #1c356b);
filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#2666c3', endColorstr='#1c356b',GradientType=0 );
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 20px 20px rgba(255, 255, 255, 0.12), 0 1px 1px #9c9c9c, inset 0 -1px 0 #343746;
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 20px 20px rgba(255, 255, 255, 0.12), 0 1px 1px #9c9c9c, inset 0 -1px 0 #343746;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 20px 20px rgba(255, 255, 255, 0.14), inset 0 -1px 0 #343746;
}
#cssmenu ul li.current_page_item a{
background: #2666c3;
background-repeat: repeat-x;
background-image: -khtml-gradient(linear, left top, left bottom, from(#2666c3), to(#1c356b));
background-image: -moz-linear-gradient(top, #2666c3, #1c356b);
background-image: -ms-linear-gradient(top, #2666c3, #1c356b);
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #2666c3), color-stop(100%, #1c356b));
background-image: -webkit-linear-gradient(top, #2666c3, #1c356b);
background-image: -o-linear-gradient(top, #2666c3, #1c356b);
background-image: linear-gradient(top, #2666c3, #1c356b);
filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#2666c3', endColorstr='#1c356b',GradientType=0 );
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 20px 20px rgba(255, 255, 255, 0.12), 0 1px 1px #9c9c9c, inset 0 -1px 0 #343746;
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 20px 20px rgba(255, 255, 255, 0.12), 0 1px 1px #9c9c9c, inset 0 -1px 0 #343746;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 20px 20px rgba(255, 255, 255, 0.14), inset 0 -1px 0 #343746;
}
- 谢谢**伙计们,我真的很感谢你们的帮助:)
5条答案
按热度按时间0yycz8jy1#
你是不是试着买了最后一件?
kzipqqlq2#
您可以使用其中一种
或
如果你有“子项”或“子菜单”(
<ul><ul><li>
),“最后一个类型”是很好的,因为它无论如何都会工作,但它与浏览器的兼容性较差...你也可以用多个“最后一个孩子”规则来指出这一点...检查你的CSS特性。有时你可能需要使用更高的特性来得到你想要的。
mkshixfv3#
你应该使用“+”选择器,它来自CSS 2.0,非常强大,甚至对IE 7也是如此。
cssmenu ul li{边框:无}
中文菜单ul li+li{左边框:1 px实心#颜色代码;}
这将使每个“里”的竖线都在左侧(而不是使用右侧的线),除了第一个。
bmp9r5qi4#
好的,最后一项菜单:
对于最后一个项目之前的项目,如果需要:
f8rj6qna5#
我想你得加上这条规则