Is it possible to center a div using the following CSS code:
.container {
width: 1024px;
margin: 0 auto;
}
When the container is placed inside body tags, spanning across all displayed page content, it aligns perfectly.
The challenge arises when attempting the same method with a width set to 100%. In this case, the page loses its centered position. This limits the flexibility of my page design, leading me to create multiple containers for different screen widths (in pixels).
Can anyone provide insights on creating a container that will effectively center the page with a width of 100%?
Your help is greatly appreciated.