


Reasons and solutions for firefox margin-top failure_Experience exchange
Why translate this description? Someone has translated css2, but after looking at it, it’s very rough (I’m not saying that I’m the only one, the translator is really admirable!). Recently, I’ve come into more and more contact with css and xhtml, but the The more there are, the more confusion there is.
Now I feel that many problems cannot be called problems at all. The reason lies in our hasty understanding. For example, killing a chicken with a bull's knife is not impossible, but unreasonable and inappropriate. If the root cause is wrong, the appearance will be wrong. , if you start to solve the problem from the appearance, it is inevitable that you will always be confused. As I said, you must be down-to-earth and don't be impetuous.
In this description, "collapsing margins" means: adjacent margin attributes between 2 or more box models (the relationship can be adjacent or nested) (there cannot be non- Empty content, padding area, border or using clear separation method) are combined and represented as a single margin.
In CSS2.1, horizontal margins will not be collapsed.
Vertical margins may be collapsed in some box models:
1. In regular document flow, adjacent vertical margins of 2 or more block-level box models will be collapsed.
The final margin value calculation method is as follows:
a. If all are positive values, take the largest one;
b. If not all are positive values, take the absolute value, and then subtract the maximum value from the positive value. ;
c. If there is no positive value, take the absolute value, and then subtract the maximum value from 0.
Note: Adjacent box models may be generated dynamically from DOM elements and have no adjacent or inheritance relationship.
2. In adjacent models, if one of them is floated, the vertical margin will not be collapsed, even between a floating box model and its child elements.
3. The margin between the element with the overflow attribute set and its child elements will not be folded (except when the overflow value is visible).
4. For a box model with absolute positioning (position:absolute) set, the vertical margin will not be collapsed, even with their child elements.
5. For elements with display:inline-block set, the vertical margin will not be collapsed, even with their child elements.
6. If the upper and lower margins of a box model are adjacent, its margin may collapse through it. In this case, the element's position depends on whether the margins of its adjacent elements are collapsed.
a. If the margin of an element and the margin-top of its parent element are collapsed together, the border definition of the border-top of the box model is the same as that of its parent element.
b. In addition, the parent element of any element does not participate in the folding of margin, or only the margin-bottom of the parent element participates in the calculation. If the element's border-top is non-zero, then the element's border-top position is the same as before.
The margin-top of an element that has a clear operation applied will never collapse with the margin-bottom of its block-level parent element.
Note that the position of elements that have been covered by the fold has no effect on the position of other elements that have been collapsed; the border-top border position is only necessary when laying out the child elements of these elements.
7. The vertical margin of the root element will not be collapsed.
The margin-bottom of a floating block-level element is always adjacent to the margin-top of the floated next in-flow block-level sibling element (floated next in-flow block-level sibling), unless that sibling element uses a clear operation. .
The margin-top of a floating block-level element is adjacent to the margin-top of its first floated block-level child (floated first in-flow block-level child) (if the element has no border-top, no padding-top, and child elements are not cleared).
If the margin-bottom of a floating block-level element meets the following conditions, then it is adjacent to the margin-bottom of its last floating block-level child element (if the element does not specify padding-bottom or border):
a. Height:auto is specified
b. min-height is less than the actual height of the element (height)
c. max-height is greater than the actual height of the element (height)
If the min of an element -The height attribute is set to 0, then the margins it owns are adjacent, and it has neither border-top and border-bottom, nor padding-top and padding-bottom. Its height attribute can be 0 or auto, It cannot contain an inline box model (line box), and the margins of all its floated child elements (if any) are adjacent.
When the margin owned by an element is collapsed and it uses the clear operation, its margin-top will collapse with the adjacent margin of the immediately following sibling element, but the result is that its margin will not be consistent with its margin. Margin-bottom collapse of block-level parent elements.
The folding operation is based on the values of padding, margin, and border (that is, after the browser parses all these values). The folded margin calculation will overwrite the different margin values that have been used.
//Without adding the br line, the margin-top of id1 in FIREFOX is:20px It will act on d0, so that there is a 20px gap between the top of d0 and the body, and there is no gap between d1 and d0, and it will display normally in IE

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

To remove FirefoxSnap in Ubuntu Linux, you can follow these steps: Open a terminal and log in to your Ubuntu system as administrator. Run the following command to uninstall FirefoxSnap: sudosnapremovefirefox You will be prompted for your administrator password. Enter your password and press Enter to confirm. Wait for command execution to complete. Once completed, FirefoxSnap will be completely removed. Note that this will remove versions of Firefox installed via the Snap package manager. If you installed another version of Firefox through other means (such as the APT package manager), you will not be affected. Go through the above steps

How to solve the common problem of Laravel login time expiration When using Laravel to develop web applications, login authentication is a very important function. However, sometimes if a user does not operate for a long time after logging in, the page may automatically log out or the authentication may fail. This problem is relatively common. The following will introduce how to solve this problem by setting the session time and provide specific code examples. 1. Set the session expiration time in Laravel, by default sessi

PHP and REDIS: How to implement distributed cache invalidation and update Introduction: In modern distributed systems, cache is a very important component, which can significantly improve the performance and scalability of the system. At the same time, cache invalidation and update is also a very important issue, because if the invalidation and update of cache data cannot be handled correctly, it will lead to system data inconsistency. This article will introduce how to use PHP and REDIS to implement distributed cache invalidation and update, and provide relevant code examples. 1. What is RED

Mozilla Firefox can be uninstalled; Firefox is a third-party browser and can be uninstalled if it is not needed. Uninstallation method: 1. In the Start menu, click "Windwos System" - "Control Panel"; 2. In the "Control Panel" interface, click "Programs and Features"; 3. In the new interface, find and double-click Firefox Browser icon; 4. In the uninstall pop-up window, click "Next"; 5. Click "Uninstall".

According to recent news, while Mozilla released the stable version of Firefox 112, it also announced that the next major version, Firefox 113, has entered the Beta channel and supports AV1 animations, enhanced password generator and picture-in-picture features. The main new functions/features of Firefox 113 are as follows: Support for AV1 format animated images (AVIS); Enhance the security of the password generator by introducing special characters; Enhance the picture-in-picture function, support rewind, display video time, and enable full screen more easily Mode provides official DEB installation files for Debian and Ubuntu distributions. Updated bookmark import feature, icons for imported bookmarks are supported by default. Hardware accelerated AV1 video decoding is enabled by default on supported hardware using w

For crawlers to crawl websites that require login, verification code or scan code login is a very troublesome problem. Scrapy is a very easy-to-use crawler framework in Python, but when processing verification codes or scanning QR codes to log in, some special measures need to be taken. As a common browser, Mozilla Firefox provides a solution that can help us solve this problem. The core module of Scrapy is twisted, which only supports asynchronous requests, but some websites require the use of cookies and

Today’s latest news, Mozilla officially released the Firefox 115 stable version update today. The most noteworthy thing about this update is that this is the last version that supports Win7/Win8, macOS10.12, 10.13 and 10.14. Download address: https://ftp.mozilla.org/pub/firefox/releases/115.0/Mozilla stated in the official update log: Microsoft will end support for Win7 and Win8 systems in January 2023, and Firefox 115 released today The version is the last version update received by users of said system. Win7 and Win8 users

Canonical recently announced that in the upcoming Ubuntu 23.10, Firefox Snap has been configured to run in Wayland mode by default. Note: Ubuntu currently has the Wayland session by default, and Firefox can also work normally. However, currently FirefoxSnap actually runs in XWayland compatibility mode, rather than the strict native Wayland mode. Canonical announced that it will run the Firefox browser in Wayland mode by default, so that problems such as interface blur and scaling distortion will not occur on HiDPI displays, and it will support touch gestures such as dragging and pinching. As mentioned above, Ubunt
