I’m a beginner in CSS and I wanted to test my skills, so I took up some projects to build basic websites purely from css and html. However I often got stuck in places, especially when setting up margins, padding, height etc.
How do I determine the exact values of the margin, padding etc.? Is there some mathematical calculation that people do or do you just put in random values and check if they work?
>Solution :
Here are a few ideas that might be helpful.
margin: auto-> this can help you quickly center an element without too much hassle- flex and grids -> this answer might provide some useful links
- check out different CSS units -> this answer gives a nice, brief overview
- this might be beyond what you need, but if you need to do a calculation in CSS, there’s a function for that ->
calc()