Hi,
I have a simple question about CSS. I am reading a book and I checked some online sources too, but I would appreciate if I could get a simple solution here with the example code.
I want to design a page in which the body is 1024 pixels wide, but I want the body of the page to always be in the center of the monitor.
So, for example, if the user has a monitor that is 1440px wide then the <body> will occupy the middle 1024 pixels with equal margins on the left and right. Similarly, if the user has a wider monitor, the page will still appear in the middle of the monitor.
If the user has a 1024 resolution screen, then I do not want any margins to appear on the left and right side.
If the user has a monitor with less than 1024 resolution, then a horizontal bar can appear.
What I have been doing thus far is something like this
#central_area{
margin-left:10%; width:80%; margin-right: 10%;
}
However, I would like to be a bit more precise and ensure that the width is always 1024 pixels, and the margins vary according to the resolution of the monitor.
If someone can give me examples, I would appreciate it.
Thank you.
I have a simple question about CSS. I am reading a book and I checked some online sources too, but I would appreciate if I could get a simple solution here with the example code.
I want to design a page in which the body is 1024 pixels wide, but I want the body of the page to always be in the center of the monitor.
So, for example, if the user has a monitor that is 1440px wide then the <body> will occupy the middle 1024 pixels with equal margins on the left and right. Similarly, if the user has a wider monitor, the page will still appear in the middle of the monitor.
If the user has a 1024 resolution screen, then I do not want any margins to appear on the left and right side.
If the user has a monitor with less than 1024 resolution, then a horizontal bar can appear.
What I have been doing thus far is something like this
#central_area{
margin-left:10%; width:80%; margin-right: 10%;
}
However, I would like to be a bit more precise and ensure that the width is always 1024 pixels, and the margins vary according to the resolution of the monitor.
If someone can give me examples, I would appreciate it.
Thank you.