html两个按钮间距消失,两个input之间或者input与button之间有空隙/间距(不能紧贴一起)解决方法!...

编程入门 行业动态 更新时间:2024-10-08 07:37:13

html两个按钮<a href=https://www.elefans.com/category/jswz/34/1761496.html style=间距消失,两个input之间或者input与button之间有空隙/间距(不能紧贴一起)解决方法!..."/>

html两个按钮间距消失,两个input之间或者input与button之间有空隙/间距(不能紧贴一起)解决方法!...

如上图所示,代码如下:

在写搜索的时候,需要用到form、两个input或者input+button,但在写到CSS的时候,可能会遇到两个input之间或者input和button之间有空隙间距存在,那么如何解决呢?

看有空隙的CSS:.search .text{width: 210px; height: 30px;line-height: 30px;margin-left: 30px; padding-left: 10px;margin-top: 20px;

border: 3px solid #0073c6;}

.search .submit{width: 60px;height: 36px;line-height: 36px;margin-top: 20px;

background-color:#e84807;border: 0;color: #fff;text-align: center;}

此时的CSS,会显示如上图,中间存在空隙!

解决方法:

在CSS第一行中,加入float:left,使input以及button浮动即可解决!

加入float:left后CSS:.search .text{float:left;width: 210px; height: 30px;line-height: 30px;margin-left: 30px; padding-left: 10px;margin-    top: 20px;border: 3px solid #0073c6;}

.search .submit{width: 60px;height: 36px;line-height: 36px;margin-top: 20px;

background-color:#e84807;border: 0;color: #fff;text-align: center;}

解决后截图:

如果你说此时也不好看,那么去修改CSS,不再简写input的蓝色边框,只保留上下左,右侧去除即可,或者移动右侧button,左侧移3px(margin-left:-3px)一样可以解决!

更多推荐

html两个按钮间距消失,两个input之间或者input与button之间有空隙/间距(不能紧贴一起)解决方法!...

本文发布于:2024-03-08 20:01:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1722134.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:间距   两个   空隙   解决方法   按钮

发布评论

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

>www.elefans.com

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