文本重叠字体真棒图标

时间:2018-01-17 03:36:47

标签: html css bootstrap-4

我对我的联系表单非常满意,但是邮件区域中的文本与图标重叠。我发现这很奇怪,因为它开始于一个完美的缩进,但随着人们写得更多,它会直接进入图标。任何人都可以帮助解决这个小问题。我添加了一张照片。 enter image description here我的代码如下:

<!--Contact-->

<div class="container">
  <div class="row">
    <div class="col-md-12">
      <div class="well well-sm">
        <form class="form-horizontal" method="post">
          <fieldset>

            <div class="form-group">
              <div class="col-md-8">
                <div class="input-wrapper">
                  <input id="fname" name="name" placeholder="Name" type="text" class="form-control">
                  <label for="fname" class="fa fa-user input-icon bigicon"></label>
                </div>
              </div>
            </div>
            <div class="form-group">
              <div class="col-md-8">

                <div class="input-wrapper">
                  <input id="email" name="email" type="text" placeholder="Email" class="form-control">
                  <label for="email" class="fa fa-envelope-o input-icon bigicon"></label>
                </div>
              </div>
            </div>

            <div class="form-group">
              <div class="col-md-8">

                <div class="input-wrapper">

                  <textarea class="form-control" id="message" name="message" placeholder="Message" rows="3"></textarea>
                  <label for="message" class="fa fa-pencil-square-o input-icon bigicon"></label>
                </div>
              </div>
            </div>

            <div class="form-group">
              <div class="col-md-12 text-center">
                <button type="submit" class="btn btn-outline-secondary btn-md">Submit</button>
              </div>
            </div>
          </fieldset>
        </form>
      </div>
    </div>
  </div>
</div>



  html{
  box-sizing: border-box;}
  *,
  *: before, 
  *: after {
    box-sizing: inherit;
    padding: 0;
    margin: 0;
  }
  body{background-image: url();
   width: 100%;
  height: 100%;
  background-position: bottom center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  background-color: #464646;
  font-family:"Quicksand";
  font-size: 1.2em;
  line-height: 1.375em;
  padding: 0;
  margin: 0;
  background-color: #2F3A3B;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;

  }

 navbar-brand{

    height: 3em;
    width: 3em;
    margin-top: -8px;
    border-radius: 5.0em;
    margin-right: 1em;
    margin-left: -5em;
    margin-bottom: -8px
}

.avatar{
border-radius: 5em;
margin-right: .5em;
margin-left: 1em;

}
  .intro{
    display: inline-block;
    width: 100%;
    padding: 65px 0 65px;
    background-color: #2A2332;
    background-size: cover;
    font-size: 1.9em;
    text-align: center;
    color: #FFF;
  }

   h1{
    font-weight: medium;
    text-shadow:5px 5px 10px black;
  }

  h4{
    font-size: -.5em;
  }


.row{
  margin-right: 4em;
  margin-left: 4em;
  margin-top: .10em;
  padding-bottom: -.30em;

}

.container {
  margin-left: 17em;
  padding-top: 1.5em;

}

.bigicon {
  font-size: 35px;
  color: #808080;

}

.input-icon {
  position: absolute;
  left: .5rem;
  top: calc(50% - 0.5em);

  /* Keep icon in center of input, regardless of the input height */
}


#message {
  vertical-align: middle;
}
input {

  padding-right:30px;

}

.form-control {
  text-indent: 2rem;
  width: 75%;




}

.input-wrapper {
  position: relative;


}

.btn{

  margin-right: 10em;

}


  @media screen and (min-width: 640px){


  }

  @media screen and (min-width: 960px){

  }
[![enter image description here][1]][1]
  main {flex: 1;}

1 个答案:

答案 0 :(得分:1)

试试这个代码段。我已将输入图标更改为与输入文本对齐。

&#13;
&#13;
html {
  box-sizing: border-box;
}

*,
*: before,
*: after {
  box-sizing: inherit;
  padding: 0;
  margin: 0;
}

body {
  background-image: url();
  width: 100%;
  height: 100%;
  background-position: bottom center;
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  background-color: #464646;
  font-family: "Quicksand";
  font-size: 1.2em;
  line-height: 1.375em;
  padding: 0;
  margin: 0;
  background-color: #2F3A3B;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

navbar-brand {
  height: 3em;
  width: 3em;
  margin-top: -8px;
  border-radius: 5.0em;
  margin-right: 1em;
  margin-left: -5em;
  margin-bottom: -8px
}

.avatar {
  border-radius: 5em;
  margin-right: .5em;
  margin-left: 1em;
}

.intro {
  display: inline-block;
  width: 100%;
  padding: 65px 0 65px;
  background-color: #2A2332;
  background-size: cover;
  font-size: 1.9em;
  text-align: center;
  color: #FFF;
}

h1 {
  font-weight: medium;
  text-shadow: 5px 5px 10px black;
}

h4 {
  font-size: -.5em;
}

.row {
  margin-right: 4em;
  margin-left: 4em;
  margin-top: .10em;
  padding-bottom: -.30em;
}

.container {
  margin-left: 17em;
  padding-top: 1.5em;
}

.bigicon {
  font-size: 35px;
  color: #808080;
}

.input-icon {
  position: absolute;
  left: .5rem;
  top: .9rem;
  /* Keep icon in center of input, regardless of the input height */
}

#message {
  vertical-align: middle;
}

input {
  padding-right: 30px;
}

input.form-control {
  padding-left: 2rem;
}

.input-wrapper {
  position: relative;
}

textarea.form-control {
  padding-left: 2rem;
}

.btn {
  margin-right: 10em;
}

@media screen and (min-width: 640px) {}

@media screen and (min-width: 960px) {}
&#13;
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">

<!--Contact-->

<div class="container">
  <div class="row">
    <div class="col-md-12">
      <div class="well well-sm">
        <form class="form-horizontal" method="post">
          <fieldset>

            <div class="form-group">
              <div class="col-md-8">
                <div class="input-wrapper">
                  <input id="fname" name="name" placeholder="Name" type="text" class="form-control">
                  <label for="fname" class="fa fa-user input-icon bigicon"></label>
                </div>
              </div>
            </div>
            <div class="form-group">
              <div class="col-md-8">

                <div class="input-wrapper">
                  <input id="email" name="email" type="text" placeholder="Email" class="form-control">
                  <label for="email" class="fa fa-envelope-o input-icon bigicon"></label>
                </div>
              </div>
            </div>

            <div class="form-group">
              <div class="col-md-8">

                <div class="input-wrapper">

                  <textarea class="form-control" id="message" name="message" placeholder="Message" rows="3"></textarea>
                  <label for="message" class="fa fa-pencil-square-o input-icon bigicon"></label>
                </div>
              </div>
            </div>

            <div class="form-group">
              <div class="col-md-12 text-center">
                <button type="submit" class="btn btn-outline-secondary btn-md">Submit</button>
              </div>
            </div>
          </fieldset>
        </form>
      </div>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;