twitter-bootstrap 表行 <td> 中的 Twitter Bootstrap 下拉菜单

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18186003/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 17:56:08  来源:igfitidea点击:

Twitter Bootstrap dropdown in table row <td>

twitter-bootstrap

提问by user1555190

Im trying to get a drop down to appear in a table row, in a specific column, but it doesnt seem to be working.

我试图让下拉菜单出现在表格行的特定列中,但它似乎不起作用。

Im using chrome, but i cant seem to get it to work, i have tried to follow many exmaples, but none seem to work.

我使用 chrome,但我似乎无法让它工作,我试图遵循许多例子,但似乎没有一个工作。

<!DOCTYPE HTML>
<%@ page isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/bootstrap/bootstrap.js"></script>
      <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/resources/css/bootstrap/bootstrap.css">
   </head>
   <body style="overflow: hidden;">
      <div class="container" align="center">
         <h1 style="margin-top: 100px;">Admin Page</h1>
         <table class="table table-bordered">
            <thead>
               <tr>
                  <th>Id</th>
                  <th>Game</th>
                  <th>Bonus</th>
               </tr>
            </thead>
            <tbody>
               <tr>
                  <td>1</td>
                  <td>Treasure Island</td>
                  <td>
                     <div class="dropdown">
                        <a data-target="#" data-toggle="dropdown" class="dropdown-toggle" href="#">Dropdown menu here...
                        <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu">
                           <li><a href="/app/1">Item A</a></li>
                           <li><a href="/app/2">Item B</a></li>
                           <li><a href="/app/3">Item C</a></li>
                        </ul>
                     </div>
                  </td>
               </tr>
            </tbody>
         </table>
      </div>
   </body>
</html>     

回答by Tim

Assuming you want that dropdown triggered by a button, you could do something like this...

假设您希望通过按钮触发下拉菜单,您可以执行以下操作...

<div class="btn-group">
    <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
        Action
        <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
        <!-- dropdown menu links -->
    </ul>
</div>