简体   繁体   English

使用CSS在页面中定位div时出现问题

[英]Problem positioning div in page with css

I'm having a problem trying to position a div in my web page, here's my test site: http://dirtymind.jvsoftware.com/ 我在尝试在网页中放置div时遇到问题,这是我的测试网站: http : //dirtymind.jvsoftware.com/

The problem is with the left side bar (the one with the login inputs and stuff), it's currently a div which I used negative top and left margins to position it where it is, but depending on the screen resolution it moves to the left or right. 问题出在左侧栏(一个带有登录输入和内容的栏)上,它当前是一个div,我使用负的上下边距将其定位在原处,但是取决于屏幕分辨率,它会向左移动或对。 Obviously this is beacuse I'm using margins this is how css would work but I don't know how to get this same results otherwise. 显然,这是因为我使用的是margins,这就是css的工作方式,但是我不知道如何获得相同的结果。

Does anyone know how to position my sidebar on place regarding the resolution? 有人知道如何将我的侧边栏放置在与分辨率有关的位置吗?

Thanks all in advance. 提前谢谢大家。

Well you already have a wrapper in place.... Why not give it a hard width of the main content area+the width of the side bar and any spacing you want between the two. 好了,您已经有了一个包装器。...为什么不给它一个主要内容区域的硬宽度+侧栏的宽度以及两者之间想要的任何间距。 then you can just float both of them to the left. 那么您只需将它们都向左浮动即可。 Or you could set the wrappr to position relative (not assigning a position) and then use position absolute on the side bar and punh in the coordinates from 0 point of the wrapper. 或者,您可以将wrappr设置为相对位置(不分配位置),然后在侧栏上使用绝对位置,在包装器0点开始的坐标中使用punh。

Yeah what he said: 是的,他说的是:

<div id='wrapper' style='width:800px'>
  <div id='left-sidebar' style='width:200px;float:left'>
     ...content...
  </div>

  <div id='contenedor' style='width:600px;float:left'>
     ...content...
  </div>

</div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM