下拉菜单项不会显示

时间:2017-05-17 17:53:42

标签: twitter-bootstrap drop-down-menu dropdownbox

我编写了一个下拉菜单按钮,这个显示正确,但没有下拉,我的源代码是这样的:

    <!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Agregar Solicitud de Soporte</title>
    <!-- Bootstrap CSS File  -->
    <link rel="stylesheet" type="text/css" href="bootstrap-3.3.5-dist/css/bootstrap.css"/>
    <LINK tpe='text/css' rel='StyleSheet' href='marn.css'>
</head>
<body>
    <div class='container'>
        <div class='row'>
            <div class="col-md-6 col-md-offset-3">
                <h1 class="page-header text-center">Solicitud de Soporte Tecnico</h1>
                <form class="form-horizontan l" role="form" method="post" action "addsoporte.php">
                    <div class="form-group">
                        <label for="txtdessop" class="col-sm-2 control-label">Descripcion</label>
                            <div class="col-sm-10">
                                <textarea class="form-control" rows="5" name="txtdessop" 
                                placeholder="Descripcion de la Solicitud del Soporte"></textarea>
                            </div>
                    </div>

                    <div class="form-group">
                        <label for="txtmodsop" class="col-sm-2 control-label">Modulo Afectado</label>
                            <div class="col-sm-10">
                                    <button type="button" class="btn btn-default dropdown-toggle" 
                                    data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" 
                                    id="txtmodsop" >Seleccione...
                                        <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu" aria-labelledby="txtmodsop">
                                        <li>Estadisticas</li>
                                        <li>Indicadores</li>
                                        <li>Inv. Estadisticas</li>
                                        <li>Metodologia</li>
                                        <li>Glosario</li>
                                        <li>Publicaciones</li>                                                                                                                                                                                                      
                                    </ul>
                            </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-10 col-sm-offset-2">
                            <a href='javascript: history.go(-1)' id="cancelar" name="cancelar" class="btn btn-warning">Cancelar</a>                 
                            <input id="enviarsoporte" name="enviarsoporte" type="submit" value="Enviar" class="btn btn-primary">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body>     
</html>

此时我找不到问题,我已经查了很多例子,它们就像我的源代码,但仍然无效。任何建议将不胜感激。一切顺利

3 个答案:

答案 0 :(得分:1)

使用<select>代码而不是<button>

<body>
    <div class='container'>
        <div class='row'>
            <div class="col-md-6 col-md-offset-3">
                <h1 class="page-header text-center">Solicitud de Soporte Tecnico</h1>
                <form class="form-horizontan l" role="form" method="post" action "addsoporte.php">
                    <div class="form-group">
                        <label for="txtdessop" class="col-sm-2 control-label">Descripcion</label>
                            <div class="col-sm-10">
                                <textarea class="form-control" rows="5" name="txtdessop" 
                                placeholder="Descripcion de la Solicitud del Soporte"></textarea>
                            </div>
                    </div>

                    <div class="form-group">
                        <label for="txtmodsop" class="col-sm-2 control-label">Modulo Afectado</label>
                            <div class="col-sm-10">

                                     <select class="form-control" id="yourTitle">
                                        <option>Estadisticas</option>
                                        <option>Indicadores</option>
                                        <option>Inv. Estadisticas</option>
                                        <option>Metodologia</option>
                                        <option>Glosario</option>
                                        <option>Publicaciones</option>
                                      </select>
                            </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-10 col-sm-offset-2">
                            <a href='javascript: history.go(-1)' id="cancelar" name="cancelar" class="btn btn-warning">Cancelar</a>                 
                            <input id="enviarsoporte" name="enviarsoporte" type="submit" value="Enviar" class="btn btn-primary">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</body> 

答案 1 :(得分:0)

您需要包含bootstrap.min.js。请添加脚本标签,如下所示,然后检查。

 <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Agregar Solicitud de Soporte</title>
        <!-- Bootstrap CSS File  -->
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.5-dist/css/bootstrap.css"/>
        <LINK tpe='text/css' rel='StyleSheet' href='marn.css'>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
      <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    </head>

答案 2 :(得分:0)

您需要包含Bootstrap JavaScript文件以及下拉功能。

注意底部的JQuery和Bootstrap脚本

<html>
<head>
    <meta charset="UTF-8">
    <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>
</head>
<body>
    <div class="dropdown">
        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
            Seleccione...
            <span class="caret"></span>
        </button>
        <ul class="dropdown-menu">
            <li>Estadisticas</li>
            <li>Indicadores</li>
            <li>Inv. Estadisticas</li>
            <li>Metodologia</li>
            <li>Glosario</li>
            <li>Publicaciones</li>
        </ul>
    </div>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
    <script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'></script>
</body>
</html>