html消除button之间的间距

关于html中input标签中button属性和button标签的奇怪现象,有助于解决消除button之间的默认间距,代码如下,复制即用,谢谢!
(其实直接用margin属性就可以消除间距)

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>按钮之间的距离</title>
<style type="text/css">
*{padding:0;margin:0;border:none;text-decoration:none;}/*删除浏览器中带有的默认格式*/
#test{width:200px;height:400px;margin:0 auto;border:#093 solid 1px;}
#test button{width:50px;height:30px;background-color:#093;}
#test input{width:50px;height:30px;background-color:#963;border:#000 solid 1px;}
#test .te5{width:50px;height:30px;background-color:#963;border:#000 solid 1px;}
#test .te6{width:50px;height:30px;background-color:#963;border:#000 solid 1px;margin-left:-8px;/*input设置margin的位置*/}
</style>
</head>
<body>
<div id="test">
<p style="font-size:14px; color:#096">button标签</p>
<p>1、不换行</p>
<button type="button" class="btn1">test1</button><button type="button" class="btn2">test2</button><br />
<p>2、换行</p>
<button type="button" class="btn1">test1</button><!--此处换行--->
<button type="button" class="btn2">test2</button><br /><br /><br />
<p style="font-size:14px; color:#096">input标签</p>
<p>1、不换行</p>
<input type="button" value="test3" /><input type="button" value="test4" /><br />
<p>2、换行</p>
<input type="button" value="test3" /><!--此处换行--->
<input type="button" value="test4" /><br />
<p>3、margin解决间距</p>
<input type="button" value="test5" class="te5"/><!--此处换行--->
<input type="button" value="test6" class="te6"/><br />
</div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值