-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix gasp between backgrounds of body and sidebar divs #357
base: master
Are you sure you want to change the base?
Conversation
The issue is the linear-gradient in the body background seems to not working really correctly with pixel dimensions (in Firefox at least): if you zoom in / out the page you'll see the body background to not always correctly update the rendering (and so you'll see a growing gasp for example). Due to this issue, there was a gap between the backgrounds of the body and the sidebar elements. PR linuxfrorg#354 tried to solve this by adjusting the linear-gradient pixel dimensions, but due to the bug of linear-gradient implementation, it was not working when window was resized or page zoomed. As the linear-gradient usage in the body background was clearly already a workaround to create two vertical color stripes, we replace it with another workaround using the CSS feature which allows to define multiple background images with different size and position. First background image is defined with the sidebar color (using linear-gradient with only one color) and the width which resolve the pixel gasp reported in linuxfrorg#354 (which means the width should be the branding width + body border width). To be able to define a color as an image, we use again linear-gradient, but, this time it fills all the stripe with the same color, so we won't have error due to linear-gradient implementation. Second image is defined from the first image position for the rest of the body block with the container color. This new workaround idea comes from this StackOverflow answer which explain how to create pixel perfect horizontal stripes: https://stackoverflow.com/a/24829344
The pixel alignment problem was fixed by adding no-repeat the the background: without it Firefox does not anchor the background precisely, it does it in increments of about 5px, because it assumes since the background repeats it's not a big deal, I suppose? When I added the background-size it didn't change anything in my tests. |
background-repeat: no-repeat; | ||
background-size: $PX_BRANDING_LARG + $PX_BODY_BORDER_WIDTH_LEFT_RIGHT, auto; | ||
background-position: 0, $PX_BRANDING_LARG + $PX_BODY_BORDER_WIDTH_LEFT_RIGHT; | ||
background-image: linear-gradient($C_CLAIR, $C_CLAIR), linear-gradient($C_CONTAINER, $C_CONTAINER); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well if you use two gradients why not just use two plain colours?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
background-image
CSS rule requires an image
, so we can't use directly plain colours. The hack is to use linear-gradiant
to create an image with just the plain color.
Due to the usage of background-image
, I had to disable the background-repeat
, otherwise only one of the colour is rendered everywhere.
En fait, il faut toutes les instructions ensemble pour que ça marche. On dit d'abord que l'a 2 images pour créer le background (les images sont crées avec Pour pouvoir afficher les 2 images, je dois supprimer le Comme on a 2 images, il faut dire la taille d'affichage de chacune avec Avec tout ça, Firefox est capable de faire au pixel près les 2 bandes de couleurs verticales. En théorie |
The issue is the linear-gradient in the body background seems to not working really correctly with pixel dimensions (in Firefox at least): if you zoom in / out the page you'll see the body background to not always correctly update the rendering (and so you'll see a growing gasp for example).
Due to this issue, there was a gap between the backgrounds of the body and the sidebar elements. PR #354 tried to solve this by adjusting the linear-gradient pixel dimensions, but due to the bug of linear-gradient implementation, it was not working when window was resized or page zoomed.
As the linear-gradient usage in the body background was clearly already a workaround to create two vertical color stripes, we replace it with another workaround using the CSS feature which allows to define multiple background images with different size and position.
First background image is defined with the sidebar color (using linear-gradient with only one color) and the width which resolve the pixel gasp reported in #354 (which means the width should be the branding width + body border width). To be able to define a color as an image, we use again linear-gradient, but, this time it fills all the stripe with the same color, so we won't have error due to linear-gradient implementation.
Second image is defined from the first image position for the rest of the body block with the container color.
This new workaround idea comes from this StackOverflow answer which explain how to create pixel perfect horizontal stripes: https://stackoverflow.com/a/24829344