2017-04-21 43 views
0

如何消除2个内容之间的小差距?

*, *:before, *:after {-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;} 
 
input[type="text"] { 
 
    
 
    background-color: green; 
 
    padding: 7px; 
 
    font-family: helvetica, arial, sans-serif; 
 
    font-size: 1.2em; 
 
    margin-bottom: 20px; 
 
    display: block; 
 
    border: solid 2px #bbb; 
 
    color: white; 
 
} 
 
input[type="submit"] { 
 
    background-color:blue; 
 
    font-family: helvetica, arial, sans-serif; 
 
    font-size: 1.0em; 
 
    font-weight:bold; 
 
    padding: 7px; 
 
    color: white; 
 
} 
 
input[type="submit"]:hover { 
 
    background-color: #ff379f; 
 
    color: #fafafa; 
 
} 
 
#subscription-email-text-field { 
 
    vertical-align: top; 
 
    display:inline-block; 
 
    font-size:0.9em; 
 
    font-weight:400; 
 
    border:0; 
 
    width:250px; 
 
    height:32px; 
 
    margin:0; 
 
} 
 
#subscribe-button { 
 
    display:inline-block; 
 
    border: 1px solid black; 
 
    border-width:0px 0px 0px 1px; 
 
    margin:0; 
 
    height:32px; 
 
}
<input type="text" id="subscription-email-text-field" name="email" placeholder="box 1"> 
 
<input type="submit" id="subscribe-button" value="subscribe">

我有一个文本框和一个按钮,我希望把它内联。但不知何故,它们之间有一个小的差距。

我试图建立填充和利润率,但它不会改变

如何去除呢?所以它看起来像这样 Example

+0

为什么你更新你的问题吗?现在答案和问题变得相同 –

回答

1

删除元素之间的空间。你在两个input元素之间有一个空间,所以你正在得到那个不需要的空间。

尝试以下片断

*, *:before, *:after {-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;} 
 
input[type="text"] { 
 
    
 
    background-color: green; 
 
    padding: 7px; 
 
    font-family: helvetica, arial, sans-serif; 
 
    font-size: 1.2em; 
 
    margin-bottom: 20px; 
 
    display: block; 
 
    border: solid 2px #bbb; 
 
    color: white; 
 
} 
 
input[type="submit"] { 
 
    background-color:blue; 
 
    font-family: helvetica, arial, sans-serif; 
 
    font-size: 1.0em; 
 
    font-weight:bold; 
 
    padding: 7px; 
 
    color: white; 
 
} 
 
input[type="submit"]:hover { 
 
    background-color: #ff379f; 
 
    color: #fafafa; 
 
} 
 
#subscription-email-text-field { 
 
    vertical-align: top; 
 
    display:inline-block; 
 
    font-size:0.9em; 
 
    font-weight:400; 
 
    border:0; 
 
    width:250px; 
 
    height:32px; 
 
    margin:0; 
 
} 
 
#subscribe-button { 
 
    display:inline-block; 
 
    border: 1px solid black; 
 
    border-width:0px 0px 0px 1px; 
 
    margin:0; 
 
    height:32px; 
 
}
<input type="text" id="subscription-email-text-field" name="email" placeholder="box 1"><input type="submit" id="subscribe-button" value="subscribe">

+0

你改变了什么风格?@Harikrishnan N –

+0

所以我应该在一行中输入我的html代码? –

+0

@ReynaldHenryleo是的 –

相关问题