我有一个XSLT脚本来输出一个简单的垂直菜单,但是在我的几个链接上,文本没有包装,我不明白为什么!
尝试将DIV放入链接中,以及
包含文本但无效。
以前有人遇到过这种问题吗?
XSLT:
<xsl:template match="/">
<xsl:variable name="items" select="$currentPage/ancestor-or-self::* [@isDoc and @level = 2]/* [@isDoc and string(umbracoNaviHide) != '1']"/>
<!-- The fun starts here -->
<div id="subnavtitle">
<xsl:value-of select="$currentPage/@nodeName" />
</div>
<xsl:if test="count($items) > 0">
<ul>
<xsl:for-each select="$items">
<li>
<xsl:if test="@id = $currentPage/@id">
<xsl:attribute name="class">current</xsl:attribute>
</xsl:if>
<xsl:if test="@id = $currentPage/../@id">
<xsl:attribute name="class">current</xsl:attribute>
</xsl:if>
<a href="{umbraco.library:NiceUrl(@id)}" >
<p style="width: 100px;">
<xsl:value-of select="translate(@nodeName,' ',' ')"/>
</p>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</xsl:template>
CSS:
#subNavigation {
padding-top: 10px;
padding-right: 10px;
padding-left: 10px;
font-weight: bold;
font-size: 12px;
background-size: 100% auto;
margin: 0px;
}
#subNavigation ul {
margin: 0;
padding: 0;
border: 0;
outline: 0;
}
#subNavigation ul:after {
content: ".";
display: block;
font-size: 0;
height: 0;
clear: both;
visibility: hidden;
}
* html #subNavigation ul {
zoom: 1;
}
*:first-child + html #subNavigation ul {
zoom: 1;
}
#subNavigation ul li {
list-style-image: none;
list-style-type: none;
margin-left: 0px;
white-space: nowrap;
display: inline;
float: left;
background: url(Designit_Green/images/nav.png) repeat-x;
margin-bottom: 10px;
width: 150px;
}
#subNavigation li.current {
background: #FFF url(Designit_Green/images/nav-item-activeXXX.png) left top repeat-x;
}
#subNavigation li.current a:hover {
background: #FFF url(Designit_Green/images/nav-item-activeXXX.png) left top repeat-x;
}
#subNavigation li.current a {
color: #333;
}
#subNavigation li:last-child {
border: none;
}
#subNavigation a:link, #subNavigation a:visited {
padding-left: 15px;
padding-right: 0px;
padding-top: 10px;
padding-bottom: 10px;
color: #FFF;
display: block;
text-decoration: none;
}
您可以在此处查看结果:http://bellstest.info/bar-restaurant.aspx 问题在于左侧导航。
答案 0 :(得分:18)
white-space: nowrap;
中有#subNavigation ul li
,p
会继承white-space: normal;
。
将其更改为white-space: normal;
,或将p
添加到a
或{{1}}可以解决您的问题。