小黑艰难的前端啃bug之路:内联元素之间的间隙问题

今天开始学习前端项目,遇到了一个Bug调了好久,即使margin为0,但还是有空格。

小黑整理,用四种方法解决了空白问题

html 复制代码
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body >
		<div style="font-weight: bold; font-size:25px">原始状态:</div>
		<div>
			<a href="#" style="background-color: aqua;">小黑无敌酒量</a>
			<a href="#" style="background-color: red;">老黑驴</a>
		</div>
		<div style="font-weight: bold; font-size:30px;margin-bottom: 20px;">三种方法:</div>
		<div style="font-weight: bold; font-size:25px;">(1)通过设置父元素font-size,消灭空格:</div>
		<div style="font-size: 0px;margin-bottom: 20px;margin-top: 10px;">
			<a href="#" style="background-color: aqua;font-size: 15px;">小黑无敌酒量</a>
			<a href="#" style="background-color: red;font-size: 15px;">老黑驴</a>
		</div>
		<div style="font-weight: bold; font-size:25px;">(2)通过设置float属性:</div>
		<div style="font-size: 0px;margin-top: 10px;">
			<a href="#" style="font-size:15px;float: left;background-color: aqua;">小黑无敌酒量</a>
			<a href="#" style="font-size:15px;float: left;background-color: red;">老黑驴</a>
			<div style="clear:both;margin-bottom: 20px;"></div>
		</div>
		
		<div style="font-weight: bold; font-size:25px;">(3)margin设置为负数:</div>
		<div style="margin-bottom: 20px;margin-top: 10px;">
			<a href="#" style="font-size:15px;background-color: aqua;">小黑无敌酒量</a>
			<a href="#" style="font-size:15px;background-color: red;margin-left: -5px;">老黑驴</a>
		</div>
		<div style="font-weight: bold; font-size:25px;">(4)word-spacing设置为负数:</div>
		<div style="margin-bottom: 20px;margin-top: 10px;word-spacing: -5px;">
			<a href="#" style="font-size:15px;background-color: aqua;">小黑无敌酒量</a>
			<a href="#" style="font-size:15px;background-color: red;">老黑驴</a>
		</div>
	</body>
</html>

下班,准备先弹琴再上瑜伽课,今天下午彩排成功,加油!!明天会更好

相关推荐
拾光拾趣录6 分钟前
浏览器对队头阻塞问题的深度优化策略
前端·浏览器
用户8122199367226 分钟前
[已完结]后端开发必备高阶技能--自研企业级网关组件(Netty+Nacos+Disruptor)
前端
万少11 分钟前
2025中了 聊一聊程序员为什么都要做自己的产品
前端·harmonyos
abigale032 小时前
webpack+vite前端构建工具 -11实战中的配置技巧
前端·webpack·node.js
专注API从业者3 小时前
构建淘宝评论监控系统:API 接口开发与实时数据采集教程
大数据·前端·数据库·oracle
Joker`s smile3 小时前
Chrome安装老版本、不同版本,自制便携版本用于前端调试
前端·chrome
weixin_416639973 小时前
爬虫工程师Chrome开发者工具简单介绍
前端·chrome·爬虫
我是如子啊3 小时前
【解决“此扩展可能损坏”】Edge浏览器(chrome系列通杀))扩展损坏?一招保留数据快速修复
前端·chrome·edge
灵性花火3 小时前
Qt的前端和后端过于耦合(0/7)
开发语言·前端·qt
孤水寒月7 小时前
基于HTML的悬窗可拖动记事本
前端·css·html