html中两个按钮水平,html – 两个按钮之间的奇怪差距

问题是在内联块元素中,HTML中的空格成为屏幕上的可视空间.解决它的一些解决方案:

>使用font-size:0到父容器(您必须为子元素定义font-size):

.buttons {

width: 304px;

margin: 0 auto;

z-index: 9999;

margin-top: 40px;

font-size: 0;

}

button {

background-color: transparent;

border: 1px solid dimgray;

width: 150px;

height: 40px;

cursor: pointer;

}

Button1

Button2

>另一个是使用负边距 – 左:-4px

.buttons {

width: 304px;

margin: 0 auto;

z-index: 9999;

margin-top: 40px;

}

button {

background-color: transparent;

border: 1px solid dimgray;

width: 150px;

height: 40px;

cursor: pointer;

margin-left: -4px;

}

Button1

Button2

>最后但我完全不喜欢使用html注释作为间隔符

差距之间:

.buttons {

width: 304px;

margin: 0 auto;

z-index: 9999;

margin-top: 40px;

}

button {

background-color: transparent;

border: 1px solid dimgray;

width: 150px;

height: 40px;

cursor: pointer;

}

Button1Button2

以上都可行.祝好运 :)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值