在菜单上悬停时显示文字

时间:2013-03-06 21:32:28

标签: html css twitter-bootstrap

我一直在使用twitter bootstrap在我的网站上工作,有一件事我可能做得不对。

当我将鼠标悬停在其中一个链接上时,我希望在菜单中显示一些文字。这就是我所拥有的:

HTML:

<div class="navbar navbar-fixed-top">
        <div class="navbar-inner">
          <!-- Responsive Navbar Part 1: Button for triggering responsive navbar (not covered in tutorial). Include responsive CSS to utilize. -->
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <!-- Responsive Navbar Part 2: Place all navbar contents you want collapsed withing .navbar-collapse.collapse. -->
          <div class="nav-collapse collapse">
            <ul class="nav">
              <li><a href="portfolio.html" title="Back to Portfolio">Back</a></li>
              <li><a href="prev_page.html" class=""previous >Previous</a></li>
              <li><a href="next_page.html" class="next" >Next</a></li>
              <li><span class="shownext">View next</span></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div><!-- /.navbar-inner -->
      </div><!-- /.navbar navbar-inverse--> 

CSS:

.nav .shownext {
    font-weight: normal;
    font-style: italic;
    font-size: 11px;
    display: none;
}

.next:hover + .nav .shownext {
    display: block;
}

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:1)

您可以使用tooltips来表达或仅使用标题属性:

<div class="navbar navbar-fixed-top">
        <div class="navbar-inner">
          <!-- Responsive Navbar Part 1: Button for triggering responsive navbar (not covered in tutorial). Include responsive CSS to utilize. -->
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <!-- Responsive Navbar Part 2: Place all navbar contents you want collapsed withing .navbar-collapse.collapse. -->
          <div class="nav-collapse collapse">
            <ul class="nav">
              <li><a href="portfolio.html" data-toggle="tooltip" data-placement="left" title="first tooltip" title="Back to Portfolio">Back</a></li>
              <li><a href="prev_page.html" data-toggle="tooltip" data-placement="bottom" title="second tooltip" class=""previous >Previous</a></li>
              <li><a href="next_page.html" data-toggle="tooltip" data-placement="top" title="third tooltip" class="next" >Next</a></li>
              <li><span class="shownext" data-toggle="tooltip" data-placement="top" title="view next">View next</span></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div><!-- /.navbar-inner -->
      </div><!-- /.navbar navbar-inverse--> 

<script>$('li a').tooltip(options)</script>

结果

答案 1 :(得分:0)

这就是你问的问题。但既然你的问题不具体,我认为这不是你想要的。

http://jsfiddle.net/xM6u9/1/

<div class="navbar">
    <div class="navbar-inner"> <a class="brand" href="#">Title</a>
        <ul class="nav">
            <li class="active"><a href="#">Home</a>
            </li>
            <li><a href="#">Link</a>
            </li>
            <li><a href="#">Link</a>
            </li>
            <li class="shownext"><a href="#">Next</a>
            </li>
        </ul>
    </div>
</div>

的CSS:

.shownext { display: none; }
li:hover + .shownext { display: block; }
当您将鼠标悬停在最后一个项目上时,

显示“下一步”。