如何将输入放入其他输入

时间:2015-01-24 19:07:45

标签: css css3

我有两个input,第一个是type="text",第二个是type="submit"。我试图首先在input内显示按钮。



.inputs {
    width: 245px;
    padding: 15px 25px;
    font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
    font-weight: 400;
    font-size: 14px;
    color: #9D9E9E;
    text-shadow: 1px 1px 0 rgba(256, 256, 256, 1.0);
    background: #FFF;
    border: 1px solid #FFF;
    border-radius: 5px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
    -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
    -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
}

<form>
  <input type="email" class="inputs" placeholder="Enter your e-mail" name="email" required="required" />
  <input type="submit" value="subscribe" id="subbutton" />
</form>
&#13;
&#13;
&#13; 这就是我想要创造的 enter image description here

3 个答案:

答案 0 :(得分:1)

&#13;
&#13;
.inputs {
  width: 245px;
  padding: 15px 25px;
  font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: #9D9E9E;
  text-shadow: 1px 1px 0 rgba(256, 256, 256, 1.0);
  background: #FFF;
  border: 1px solid grey;
  border-radius: 5px 0 0 5px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
  -moz-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
  -webkit-box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
    
    /* background */
  background-image: url(http://3.bp.blogspot.com/-LjFGCzX54lw/VMP2MYfNh2I/AAAAAAAAAF4/5lfFXmCwIjk/s1600/Screenshot_1.png);
  background-repeat: no-repeat;
  background-position: right
}

input[type=submit] {
    border-radius: 0 5px 5px 0;
    background: white;
    border: solid 1px grey;
    padding: 14px 25px;
    border-left: none
}
&#13;
<form>
  <input type="email" class="inputs" placeholder="Enter your e-mail" name="email" required="required" /><!--
  --><input type="submit" value="subscribe" id="subbutton" />
</form>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

您可以通过定位图标和按钮absolute并为其提供合适的样式来实现此目的。

enter image description here

form {
  display: inline-block;
  padding: 0;
  margin: 0;
  position: relative;
}
.inputs {
  width: 245px;
  padding: 15px 82px 15px 50px;
  font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: #9D9E9E;
  text-shadow: 1px 1px 0 rgba(256, 256, 256, 1.0);
  background: #FFF;
  border: 1px solid #FFF;
  border-radius: 5px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
}
#subbutton {
  position: absolute;
  background:#EEE;
  border:none;
  font-size:1em;
  color: #3C3B39;
  right: 0;
  bottom: 2px;
  width: auto;
  font-size: 13px;
  height: calc(100% - 4px);
  box-sizing: border-box;
  border-top-right-radius: 5px;
  border-bottom-right-radius: 5px;
  cursor: pointer;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.50);
}
#subbutton:hover {
  background: #C4C4C4;
}
input:focus {
  outline: 0;
}
#subbutton::-moz-focus-inner {
  border: 0;
}
#envelope {
  position: absolute;
  width: 50px;
  height: 100%;
  line-height: 50px;
  text-align: center;
  font-size: 40px;
  background: url(http://3.bp.blogspot.com/-LjFGCzX54lw/VMP2MYfNh2I/AAAAAAAAAF4/5lfFXmCwIjk/s1600/Screenshot_1.png) no-repeat;
  background-position: 5px 10px;
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<form>
  <div id="envelope"></div>
  <input type="email" class="inputs" placeholder="Enter your e-mail" name="email" required="required" />
  <input type="submit" value="Subscribe" id="subbutton" />
</form>

答案 2 :(得分:0)

#input{
    width:260px;
    border:1px solid #ccc;
    overflow:auto;
    height:50px;
    border-radius:5px;
}

input.input{
    float:left;
    margin:0px 5px 0px 0px;
}

input#inp1{
    border:0px;
    width:150px;
    padding:15px 0px 15px 2px;
    font-size:1em;
}

input#inp2{
    border:0px;
    border-right:1px solid #ccc;
    width:50px;
    font-size:1em;
    color:#667;
    background:#fff;
    padding:16px 0px 16px 0px;
}

img.input{
    
    padding:6px 0px 0px 0px;
    
}
<form>
<div id="input">
     <input id="inp2" class="input" type="submit" name="" value="GO!">
    
    <input id="inp1" class="input" type="email" name="" value="" placeholder="Enter Email Here" required="required">
   
    <img class="input" src="http://3.bp.blogspot.com/-LjFGCzX54lw/VMP2MYfNh2I/AAAAAAAAAF4/5lfFXmCwIjk/s1600/Screenshot_1.png" width="46px">  
        
</div>
</form>