margin设置为负值的妙用

78 阅读1分钟
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
	<style>
		
		span {
			text-align: center;
			font-family: Cambria, "Hoefler Text", "Liberation Serif", Times, "Times New Roman", "serif";
			font-size: 12px;
			padding: 10px;
			border: 1px dashed #000;
			
			
			
		}
		span.left {
		margin-right: 30px;
			background: #a9d6ff;
		}
		span.right {
		margin-right: -53px;
			background: #eeb0b0;
		}
	</style>

</head>
<body>

	<span class="left">行类元素1<span class="right">行类元素2</span></span>

	


</body>
</html>

截屏2022-11-24 17.16.44.png

截屏2022-11-24 17.18.47.png

截屏2022-11-24 17.17.58.png