*, *: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 :(得分:1)
删除元素之间的空格。在两个public class MainActivity extends Activity
{
Button button1;
Button button2;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
setContentView(layout1);
}
});
button2 = (Button) findViewById(R.id.button2);
button2.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
setContentView(R.layout.layout2);
}
});
}
}
元素之间有一个空格,因此您将获得不需要的空间。
尝试以下代码段
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;
}