为什么我的输入表单不贴我的按钮?

时间:2018-12-04 17:30:06

标签: html css bootstrap-4

就像我在标题中说的那样,为什么我不能让输入表格贴上我的按钮?

我正在django网站上使用引导程序。

  <div class="container" style="margin-top: 20%; margin-bottom: 20%";>
    <div class="col-md-6 col-md-offset-3">     
        <div class="row">
            <div id="logo" class="text-center">
                <h1 style="font-size:500%";>Zaira.io</h1><p style="font-size:120%";>Test</p>
            </div>
            <form role="form" id="form-buscar">
                <div class="form-group">
                    <div class="input-group">
                        <input id="1" class="form-control input-lg" type="text" name="search" placeholder="Input Website Url" required/>
                            <span class="input-group-btn">
                                <button class="btn btn-success btn-lg" type="submit">
                                    <i class="glyphicon glyphicon-search" aria-hidden="true"></i> Search
                            </button>
                        </span>
                    </div>
                </div>
            </form>
        </div>            
    </div>
</div>

Website Screenshot

3 个答案:

答案 0 :(得分:1)

您似乎正在尝试创建input group。如果是这样,则在读取<span class='input-group-btn'>的行上,将类input-group-btn更改为input-group-append。这是a fiddle来演示所做的更改。

答案 1 :(得分:0)

查看此页面https://getbootstrap.com/docs/4.0/components/input-group/,以了解有关带有引导程序的输入组的更多信息。另外,在这种情况下,应避免使用span,因为它是内联元素,而不是用于定位obj的块元素。要定位,请根据需要使用input-group-prepend和/或input-group-append按钮等。

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="input-group mb-3">
  <input type="text" class="form-control" placeholder="Input Website Url" aria-label="Input Website Url" aria-describedby="basic-addon2">
  <div class="input-group-append">
   <button class="btn btn-outline-secondary" type="button">Search</button>
  </div>
</div>

答案 2 :(得分:0)

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container">
 <div class="col-md-6 col-md-offset-3">     
        <div class="row">
            <div id="logo" class="text-center">
                <h1 style="font-size:500%";>Zaira.io</h1>
             
            </div>
            <form role="form" id="form-buscar">
             
                <p style="font-size:120%";>Test</p>
                        <input id="1" class="form-control input-lg" type="text" name="search" placeholder="Input Website Url" required/>
    <button type="button" class="btn btn-info">
      <span class="glyphicon glyphicon-search"></span> Search
    </button>


 
    
   </form>
     </div>
   </div>
  </div>

</body>
</html>