Center an element and fix background color | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Center an element and fix background color

When using light/dark mode the background colour is only covered the container not the whole page Other then media queries,how can i reach a response design so that the container is centrally aligned in all screen sizes? Here’s the Website https://mkhaleddd.github.io/To-Do-List/ Here’s the code https://github.com/Mkhaleddd/To-Do-List/tree/master

1st Aug 2023, 8:24 AM
Mariam Khaled
5 Answers
+ 1
You can try to center the whole thing with CSS or with the <center> - HTML Tag. And it look's like you have a problem with the Textbox, because it is out of the Window, so you can't see the first 3 letter if you write something in there.
1st Aug 2023, 12:44 PM
Dominic Böing
Dominic Böing - avatar
0
I did try the center element it didnt work The textbox will show eventually when the container is correctly centered which I cant achieve I tried flexbox and didnt work
2nd Aug 2023, 1:59 AM
Mariam Khaled
0
You must center the parent, so try to center the whole body section.
2nd Aug 2023, 4:57 AM
Dominic Böing
Dominic Böing - avatar
0
Use Flexbox or Grid Layout to center-align your container both vertically and horizontally. These layout techniques can help you achieve a responsive and centered design without having to write numerous media queries. https://www.tellpopeyes.biz/
2nd Aug 2023, 5:54 AM
victor mccormicke
0
To fix the background color. Remove display flex from the body element in your CSS file. body {     margin: 0;     /* display: flex; */     height: 100vh;     width: 400vh }
2nd Aug 2023, 5:55 AM
Chris Coder
Chris Coder - avatar