/* 使用 inset 属性设置元素的位置 */
/* 示例 1: 设置固定定位的 div 元素距离页面边界的距离 */
div {
position: fixed;
inset: 10px; /* 等同于 top: 10px; right: 10px; bottom: 10px; left: 10px; */
background-color: lightblue;
}
/* 示例 2: 分别设置 top, right, bottom, left 的值 */
div {
position: absolute;
inset: 20px 40px 60px 80px; /* 等同于 top: 20px; right: 40px; bottom: 60px; left: 80px; */
background-color: lightcoral;
}
/* 示例 3: 只设置 top 和 bottom 的值,左右居中 */
div {
position: absolute;
inset: 20px auto; /* 等同于 top: 20px; bottom: 20px; left: auto; right: auto; */
margin: 0 auto; /* 让元素左右居中 */
width: 200px;
background-color: lightgreen;
}
inset 是 CSS 中的一个简写属性,用于同时设置 top、right、bottom 和 left 四个方向的距离。top 和 bottom,第二个值应用于 left 和 right。top,第二个值应用于 left 和 right,第三个值应用于 bottom。top、right、bottom 和 left。上一篇:css箭头
下一篇:bulma css
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站