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

b298cb6db3f91beb041118f1eaa40881.png

如上图所示,代码如下:

在写搜索的时候,需要用到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;}

解决后截图:

7c3e39a066ec5f4fb37b90c48d6bf455.png

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

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值