85-(BOM)获取元素盒子的宽高

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>14_获取元素盒子的宽高</title>
	<style>
		* {
			margin: 0;
			padding: 0;
		}
		.box {
			width: 500px;
			height: 500px;
			background-color: orange;
			border: 10px solid red;
			padding: 10px;
		}
	</style>
</head>
<body>
	<!-- box.offsetWidth的例子 -->
	<div class="box"></div>

	<!-- box.style属性的例子 -->
	<!-- <div class="box" style="width: 200px; padding: 10px; border: 10px solid red"></div> -->

	<script>
		var box = document.querySelector('.box');
		console.log(box.style);
		box.offsetWidth = 5; // '5px'
		console.dir(box.offsetWidth);
		// offsetWidth 和 offsetHeight  能够获取行内 内联 外联中的样式值, 不再像box.style中仅局限于行内

		// 获取盒子的宽高 offsetWidth offsetHeight 返回值是 数字类型 , 没有长度单位
		// offsetWidth = width + border-left-width + border-right-width + padding-left-width + padding-right-width
		// offsetHeight = height + border-left-height + border-right-height + padding-left-height + padding-right-height
		// 
		// offset...
		// 可以得到任意样式表中的样式值, 且没有单位
		// offsetWidth 包含 padding border width
		// 只可读, 不可写
		// 主要用来获取元素大小 和 位置


		// style
		// 只能获取行内样式表中的样式值, 且带有单位
		// style.width 获得的是width, 不包含padding和border的值
		// 可读 也可写(赋值)
		// 如果想给元素改值 用style
	</script>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
JUnit-BOM(Bill of Materials)是JUnit团队为JUnit 5框架提供的一个特殊模块。它的目的是简化JUnit 5的依赖管理。通过添加JUnit-BOM到你的项目中,你可以使用JUnit 5的所有核心模块和扩展模块,而无需单独指定每个模块的版本。 要使用JUnit-BOM,你需要在你的项目的构建文件中添加一个依赖项。对于Maven项目,可以在`<dependencies>`标签中添加以下内容: ``` <dependency> <groupId>org.junit</groupId> <artifactId>junit-bom</artifactId> <version>5.x.x</version> <!-- 替换为你想要使用的JUnit 5版本 --> <type>pom</type> <scope>import</scope> </dependency> ``` 对于Gradle项目,可以在`dependencies`块中添加以下内容: ``` dependencies { testImplementation platform('org.junit:junit-bom:5.x.x') // 替换为你想要使用的JUnit 5版本 testImplementation 'org.junit.jupiter:junit-jupiter-api' // 添加其他所需的JUnit 5模块 } ``` 添加JUnit-BOM之后,你可以使用JUnit 5的各种功能,例如编写和运行JUnit单元测试。你可以使用`@Test`注解来标记测试方法,并使用JUnit提供的各种断言和注解来编写强大的单元测试。 通过引用JUnit-BOM,你可以确保你的项目使用与JUnit 5兼容的版本,并且可以轻松管理依赖关系。这使得在不同的项目中使用JUnit 5变得更加简单和一致。 JUnit-BOM的详细信息可以在JUnit官方文档中找到。 JUnit是一个用于编写和运行可重复自动化测试的Java单元测试框架。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

七色的天空

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值