Pls explain someone this code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Pls explain someone this code

background : #2e576b; background: hsl(85, 180, 176); background-image: radial-gradient(circle at center, hsl(200, 40%, 30%), hsl(200, 40%, 40%), hsl(200, 40%, 60%));

30th Oct 2020, 7:05 PM
WarLord
WarLord - avatar
2 Answers
+ 2
The first 2 lines set background-color. The lines say "background" instead of "background-color" but since the value is a colour and within background the background-color is most appropriate, background-color is where it'll go. #2e576b describes a colour with red green and blue brightness values. 2e is hexadecimal for 46 meaning the red brightness will be 46/255 of full available red brightness. The 57 is hex for 87 so green will be 87/255 bright and the 6b is hex for 107 so blue will be 107/255 bright. The number is very precise but in words, it'll roughly be a dark bluish green since blue is brightest and green is second brightest. None of the components are close to 255 which makes it a dark colour. hsl is a function that returns a colour. It is just another way to describe a colour in terms of hue, saturation, and luminosity. If those 2 lines were specified in the same CSS rule, the last supported value will take effect. In other words, if hsl is supported by the browser, its colour will be used instead of #2e576b. The background-image is set to a gradient that'll transition through the specified colours on the way out from its centre. Colour will be a function of distance from centre of the element so the different colours will look like fuzzy rings. Since the colours are very similar, it'll be a very subtle looking gradient unless the element is small. The gradient will make the background-color invisible so it'll sort of override it. The reason the 3 lines are written with partly overlapping purposes is likely to express the most advanced intent with the gradient and then have the 2 background colours as backup if the gradient doesn't work.
31st Oct 2020, 2:59 AM
Josh Greig
Josh Greig - avatar
+ 2
Thanks for supporting...
31st Oct 2020, 5:42 AM
WarLord
WarLord - avatar