7

我有一个 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) &gt; 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 问题在于左侧导航。

4

1 回答 1

23

你有white-space: nowrap;在你的#subNavigation ul li,它会被你的继承p

将其更改为white-space: normal;,或添加white-space: normal;pora应该可以解决您的问题。

于 2012-05-12T12:15:07.547 回答