当前位置:网站首页>Padding percentage operation

Padding percentage operation

2022-06-26 17:55:00 Dandan's servant

stay css Inside padding The value can also be set as a percentage

  • 1. If position The attribute is static 、 relative or sticky, The containing block is the block level element of the nearest ancestor of the element content decision
  • 2. If position The attribute is absolute、fixed, Include blocks plus padding, namely content + padding.
<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title></title>
		<style> body {
       width: 1000px; height: 500px; padding: 100px; } .out {
       position: relative; width: 200px; height: 100px; padding: 10%; } .inner {
       position: absolute; width: 100px; height: 50px; padding: 10%; } </style>
	</head>
	<body>
		<div class="out">
			<div class="inner">inner</div>
		</div>
	</body>
</html>

padding

原网站

版权声明
本文为[Dandan's servant]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261723037019.html