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

今天开始学习前端项目,遇到了一个Bug调了好久,即使margin为0,但还是有空格。在这里插入图片描述

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

<!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>

在这里插入图片描述

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

在这里插入图片描述

相关推荐

  1. 前端学习(HTML5 一)

    2024-01-26 07:18:01       15 阅读
  2. 前端学习(CSS3 二)

    2024-01-26 07:18:01       20 阅读
  3. 前端学习(HTML5 二)

    2024-01-26 07:18:01       16 阅读
  4. 前端学习(CSS3 一)

    2024-01-26 07:18:01       33 阅读
  5. 前端学习(事件流)

    2024-01-26 07:18:01       17 阅读
  6. 前端学习(CSS3 三)

    2024-01-26 07:18:01       25 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-26 07:18:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-26 07:18:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-26 07:18:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-26 07:18:01       18 阅读

热门阅读

  1. openssl3.2/test/certs - 060 - any.bad.com is excluded by CA2.

    2024-01-26 07:18:01       32 阅读
  2. SpringBoot整理-依赖注入

    2024-01-26 07:18:01       28 阅读
  3. 小学信息科技Python课程第3课:变量与颜色

    2024-01-26 07:18:01       29 阅读
  4. Selenium解决滑块验证问题:自动化与技巧

    2024-01-26 07:18:01       27 阅读
  5. 高防服务器什么意思

    2024-01-26 07:18:01       24 阅读
  6. 如何对高并发系统进行压力测试?重要参数详解

    2024-01-26 07:18:01       34 阅读
  7. 开机Shell脚本(20240125)

    2024-01-26 07:18:01       35 阅读