-
I am not sure about how to approach to margins and padding just by looking at the final result, in this case I adjusted values by hit and error method. But I don't think this is the right way to approach.
-
Struggled in bringing a div at the center of screen , I have to study the position topic again.
ifcoder1
@ifcoder1All comments
- @Vivek13130Submitted over 1 year ago@ifcoder1Posted over 1 year ago
I'll try to answer in a way that'll make sense.
Firstly to center your content, set your body's width to 100% and set your height to 100vh so the body's height can go from the top of your screen to the bottom of your screen. I would research css 'vh' to get a better understanding of its purpose. Then you want to set your body's display property to flex. Example: body { display: flex }. Afterwards, use justify content: center to center your content horizontally and use align-items to center your content vertically (setting your body's height to 100vh makes this process go smoothly). Lastly, you want to make sure you get rid of padding and margin by using the universal selector and setting margin and padding to 0. Example: * { margin: 0; padding: 0;}.
As for your approach to margining and padding up your content. You want to make sure you have all your content laid out first. So don't leave out any images or text that is needed to complete your project. To use padding in this project you would set your parent containers padding because padding spaces out the INNER content away from the content's BORDER. Your Inner content being your image, heading, paragraph. You can use margin to add space to elements. Watch some videos on padding and margin to get a better understanding. A way to think about it is, every element in HTML is a box. Here's a video for an explanation of CSS box model. Try to understand this as it'll help you understand what I'm saying better: https://www.khanacademy.org/computing/computer-programming/html-css/css-layout-properties/pt/css-box-model
Sorry if I'm not so clear with my feedback. Not good at explaining things through text versus in person. I hope this helps in some way.
0