小黑艰难的前端啃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>

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

相关推荐
ZengLiangYi6 小时前
Fastify 加 Electron:把 Web 服务嵌进桌面应用
前端·javascript·后端
胡图图不糊涂^_^7 小时前
测试BUG篇
学习·bug·测试
qq_2518364577 小时前
基于nodejs express +vue 天天商城系统设计与实现 (源码 文档)
前端·vue.js·express
胡萝卜术7 小时前
从零搭建生成式AI项目:OpenAI + Node.js 环境配置与密钥安全实践
前端·javascript·面试
lichenyang4537 小时前
鸿蒙实战:聊天记录持久化 · 历史会话页面 · 两个真实 Bug 的定位与修复
前端
天蓝色的鱼鱼7 小时前
前端也能写 AI Agent?用 Vercel AI SDK 十分钟跑通你的第一个智能助手
前端·ai编程
DevUI团队7 小时前
接口即代码:一个Skill轻松搞定类型定义、接口调用、Mock与调试
前端·agent·ai编程
DevUI团队7 小时前
从截图到企业级前端页面:2个Skill,1次对话,10X效率开发符合设计/编码规范的页面
前端·agent·ai编程
xiaofeichaichai7 小时前
网络与跨域
前端·网络