Problem centering div using css

I am trying to center the div on my page, but I have a very specific layout that does not allow me to focus it on a regular basis: auto properties. What I have is basically this:

HTML:

<div id="container"> <div id="sidebar"> some text </div> </div id="content"> some text </div> </div> 

CSS

 #container{ margin: 0 auto; width: 900px; } #sidebar{ float: left; width: 300px; } #content{ float: left; width: 600px; } 

This centers my container without any problems, but I need to focus the β€œcontent” div relative to the width of the screen, here is the site I'm working on so that you can see it more clearly: http://dirtymind.jvsoftware.com/ and the image I did to better explain my problem: http://dirtymind.jvsoftware.com/img/csserror.png

Does anyone know how to do this? Thanks to everyone in advance.

+1
source share
2 answers

Increase the width of the container to the width of the sidebar and add the right margin to the content block by the same amount.

+1
source

As far as I know, this is not possible, as you want it. I would choose the following options:

  • adding margin-left, say 5% to the container.
  • permanent left edge
0
source

Source: https://habr.com/ru/post/947134/


All Articles