questionCSS fixed positioning position:fixed is very easy to use. It is positioned relative to the browser's viewport. top:0;left:0 means in the upper left corner. <body> <div class="container"> </div> </body> <style> .container{ width: 100px; height: 100px; background: #888; position: fixed; top: 100px; left: 100px; } </style> When the parent element sets transform <body> <div class="BFC-box"> <div class="container"></div> </div> </body> <style> .BFC-box{ margin:200px; height: 200px; width: 200px; border:2px solid red; transform: scale(1); } .container{ width: 100px; height: 100px; background: #888; position: fixed; top: 100px; left: 100px; } </style> The fixed element is now positioned relative to its parent element. This is really annoying, because transform elevates the status of an element, as described in the W3C specification:
In elements whose transform is not none, positioning is affected. SolutionWithout affecting the layout, you can directly move the element to be positioned under the body: <body> <div class="BFC-box"></div> <div class="container"> </div> </body> If it is inconvenient to operate elements in the component, you can use js, taking vue as an example: <div ref="container" class="container"></div> mounted(){ document.body.append(this.$refs['contaier']) } This is the end of this article on how to solve the position:fixed fixed positioning offset problem. For more relevant position:fixed fixed positioning offset content, please search 123WORDPRESS.COM’s previous articles or continue to browse the related articles below. I hope that everyone will support 123WORDPRESS.COM in the future! |
<<: Summary and practice of javascript prototype chain diagram
>>: MySQL Basic Tutorial: Detailed Explanation of DML Statements
"Tik Tok" is also very popular and is s...
Example: We use the Python code loop_hello.py as ...
1. SSH remote management SSH is a secure channel ...
Founder Type Library is a font library developed ...
In daily development, front-end students often ar...
<iframe src="./ads_top_tian.html" all...
Take MySQL 5.7.19 installation as an example, fir...
What is text wrapping around images? This is the ...
How is Line-height inherited?Write a specific val...
The database installation tutorial of MySQL-8.0.2...
Background description: On an existing load balan...
1 Pull the image from hup docker pull nginx 2 Cre...
A very common scenario in react projects: const [...
Unicode is a character encoding scheme developed ...
Table of contents Preface Preview text Graphics C...