您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

css怎样去除按钮之间的间距

2024/2/25 0:25:05发布17次查看
在css中,可以利用“font-size”属性去除按钮之间的间距,按钮之间有间距是因为元素节点有文本节点,在缩进代码时会占据宽度,只需要给按钮元素的父元素添加“font-size:0;”样式即可去除间距。
本教程操作环境:windows7系统、css3&&html5版、dell g3电脑。
css怎样去除按钮之间的间距
正常情况下,当我们设置了按钮之后,按钮之间会出现间距,示例如下:
<!doctype html><html lang="en"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>document</title></head><body> <button>按钮</button> <button>按钮</button> <button>按钮</button></body></html>
输出结果:
这时候我们是需要设置按钮元素的父元素,给其父元素添加“font-size:0;”样式即可。
示例如下:
<!doctype html><html lang="en"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>document</title> <style> body{font-size:0;}</style></head><body> <button>按钮</button> <button>按钮</button> <button>按钮</button></body></html>
输出结果:
<!doctype html><html lang="en"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>document</title> <style> div{ font-size:0; width:200px; height:100px; border:1px solid red;}</style></head><body> <div> <button>按钮</button> <button>按钮</button> <button>按钮</button> </div></body></html>
输出结果:
(学习视频分享:css视频教程)
以上就是css怎样去除按钮之间的间距的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product