html - 表单输入外的 Ghlyphicons 和删除表单背景

标签 html css twitter-bootstrap glyphicons

我在 bootstrap 中有一个表单,我在输入中添加了字形,但字形出现在输入之外,我尝试应用类似问题的解决方案,但在我这样做之后,字形消失了。

我在页面上还有一个漂亮的全屏图像,但是当我添加表单时,它的白色背景覆盖了表单所在的图像部分。我曾尝试寻找解决方案,但我找不到任何东西,请帮忙。

<style>
body {
margin-top: 50px; /* Required margin for .navbar-fixed-top. Remove if using    .navbar-static-top. Change if height of navigation changes. */
}

input.transparent-input{
   background-color:transparent !important;
   border:none !important;
}

form, label, p, h3 {
    color: white !important;
}

.full {
background:url(../images/holiday_resort3-1920x1080.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}

</style>

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
    </div>
</nav>

<form class="form-horizontal">
    <fieldset>

    <!-- Form Name -->
    <legend>Book A Hotel...</legend>

    <!-- Search input-->
    <div class="form-group">
      <label class="col-md-4 control-label" for="searchinput">Search</label>
      <div class="col-md-4">
        <input id="searchinput" name="searchinput" type="search" placeholder="" class="form-control input-md">
        <span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
      </div>
    </div>

    <!-- Text input-->
    <div class="form-group">
      <label class="col-md-4 control-label" for="checkindate">Check-in:</label>  
      <div class="col-md-2">
      <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
      <input id="checkindate" name="checkindate" type="text" placeholder="" class="form-control input-md">
      </div>
    </div>

</fieldset>
</form>

<!-- jQuery -->
<script src="js/jquery.js"></script>

<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>

This is what the page looks like

I would like something along these lines instead

最佳答案

您必须在输入和图标的父级 div 中添加类 .input-group

html代码变成这样:

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
    </div>
</nav>

<form class="form-horizontal">
    <fieldset>

    <!-- Form Name -->
    <legend>Book A Hotel...</legend>

    <!-- Search input-->
    <div class="form-group">
      <label class="col-md-4 control-label" for="searchinput">Search</label>

         <div class="input-group col-md-4">

             <input id="searchinput" name="searchinput" type="search" placeholder="" class="form-control input-md">
            <span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
        </div>
    </div>


    <!-- Text input-->
    <div class="form-group">
      <label class="col-md-4 control-label" for="checkindate">Check-in:</label>  
      <div class="input-group col-md-2">
         <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
         <input id="checkindate" name="checkindate" type="text" placeholder="" class="form-control input-md">

        </div>
    </div>



</fieldset>
</form>

Working demo

关于html - 表单输入外的 Ghlyphicons 和删除表单背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40818327/

相关文章:

css - 请求 jQuery 或 CSS 方面的帮助。

css - 无法将缩略图居中

切换不同按钮文本的Javascript函数

html - 如何将文本居中放置在白色内?

html - 是否可以使用不同的图标将网页添加到主页和启动画面?

node.js - bootstrap.css 没有出现在浏览器中

css - 导航栏下拉菜单在 bootstrap4.0 中不起作用

javascript - 将导航栏元素设置为事件 onclick

css - 使用 css3 动画旋转 Div

css - Webkit 浏览器呈现的 CSS 与 Mozilla Firefox 不同......为什么?