CSS3--改变固定定位(fixed)的父级定位元素

更新时间:2023-08-08 03:44:24 阅读: 评论:0

CSS3--改变固定定位(fixed)的⽗级定位元素
css--改变固定定位(fixed)的⽗级定位元素
固定定位并不是只能相对body定位, 它的⽗级定位元素是可以⾃⼰设置的
排卵日症状⽬录
MDN 原⽂
fixed
The element is removed from the normal document flow, and no space is created for the element in the page layout. It is positioned relative to the initial containing block established by the viewport, except when one of its ancestors has a transform, perspective, or filter property t to something other than none (e the ), in which ca that ancestor behaves as the containing block. (Note that there are browr inconsistencies with perspective and filter contributing to containing block formation.) Its final position is determined by the values of top, right, bottom, and left.
就是说如果⽗级设置了transform,perspective,filter且不为none,那么它的⼦孙元素就会相对于这个⽗级进⾏固定定位
人体血液含量效果⽰例
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta chart="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
自制海苔.father {
width: 400px;
height: 400px;
/* 设置transform */
/* transform: translateX(10px); */
/* 设置perspective */
perspective: 100px;
耳石症治疗方法
/* 设置 filter */
/* filter: grayscale(100); */
background: cyan;
}
.child {
width: 200px;
height: 200px;
background: darkgoldenrod;
}
.grand-child {
/* 孙⼦元素开启固定定位 */
position: fixed;
/* 定位于底部 */
bottom: 0;
朱厚照
牛蒡茶的功效width: 100px;
height: 100px;
background: darkgreen;
}
</style>
</head>
<body>
<div class="father">
<div class="child">
<div class="grand-child"></div>
</div>
</div>
</body>
薯饼的做法</html>
效果等式的基本性质
可以看到孙⼦元素设置了 fixed 定位, 但是时相对于 father 元素定位⽽不是 body

本文发布于:2023-08-08 03:44:24,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1106753.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:定位   元素   含量   耳石   等式   自制   牛蒡
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图