如何消除2个内容之间的小差距?(How to remove small gap between 2 content?)

编程入门 行业动态 更新时间:2024-10-26 14:39:02
如何消除2个内容之间的小差距?(How to remove small gap between 2 content?)

  *, *: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"> 
  
 

我有一个文本框和一个按钮,我想让它内联。 但不知何故,它们之间存在很小的差距。

我正在尝试设置填充和边距,但它不会改变

如何删除它? 所以它看起来像这样

  *, *: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"> 
  
 

I have a textbox and a button i want to make it inline. But somehow there is a small gap between them.

I'm trying to set up the padding and margin but it doesn't change

How to remove it ? So it will look like this

最满意答案

删除元素之间的空格。 两个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"> 
  
 

Remove the space between elements. You have a space between the two input elements, so you are getting that unwanted space.

Try below snippet

  *, *: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"> 
  
 

更多推荐

本文发布于:2023-07-21 11:20:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1209761.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:差距   内容   remove   content   gap

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!