Sometimes, when applying a CSS filter
, HTML elements become repositioned.
As a simple reproducible example, follow these steps:
- Go to https://www.virustotal.com/gui/
- Click on 'Choose file' and select any local file to scan
- In the scan results page, inject this almost meaningless CSS code:
vt-ui-shell { filter: hue-rotate(0deg); }
- Click on the site's upload button, which is the up arrow located near the upper right corner of the viewport
- Notice the position of the "By submitting data below..." window displayed by the website (you may have to scroll down to see it)
- Remove the CSS code injected in step 3
- Notice that the position of the "By submitting data below..." window changes
Why does this happen and is there any way to prevent filters from doing this?
Update:
Our friend Temani Alf generously provided a link to this related question:
Why does applying a CSS-Filter on the parent break the child positioning?
I think this may explain the phenomena, but I'm interested in learning if there is a way to prevent this from happening when you can only change the CSS and not the underlying HTML code.