简体   繁体   English

HTML / CSS包装问题

[英]HTML/CSS wrapping problems

can you help me with this wrapping stuff... When I resized the browser window then everything starts to move around. 您能帮我解决这些包装问题吗?当我调整浏览器窗口的大小时,一切开始四处移动。 I managed to fix it with this one: 我设法用此解决:

#wrapper {
    margin-left:auto;
    margin-right:auto;
    width:960px;
}

but now website is too tiny. 但是现在网站太小了。 I want that it would be full screen, not 960px width.. When i make width and height auto, then everything starts to move again. 我希望它是全屏显示,而不是960px宽度。当我自动设置宽度和高度时,一切都会再次开始移动。 WHat to do? 该怎么办?

There is a problem about your styling, you use percentage for every measure, this means adapt your position based on parent side, parent is window size here. 您的样式存在问题,您为每个度量使用百分比,这意味着您将根据父侧调整位置,此处父级是窗口大小。

So it's normal everthings moving if you don't limit the wrapper width. 因此,如果不限制包装纸的宽度,一切都会正常进行。

You can use min-width to handle this. 您可以使用最小宽度来处理。

#wrapper {
       margin: 0 auto;
       min-width:960px;
   }

Normally this CSS should work: 通常,此CSS应该可以工作:

#wrapper {
    margin: 0 auto; /*center div => only alternative of your version*/
    min-width:960px;
    width: auto;
}

I suspect you want something like this: 我怀疑您想要这样的东西:
http://codepen.io/simply-simpy/pen/aOyoZM http://codepen.io/simply-simpy/pen/aOyoZM

* {
  margin: 0
}
html,body,wrap {
  height: 100%;
}
.content {
  width: 960px;
  margin: 0 auto;
  background: #eee;
  height: 100%;
  font-size: 36px;
}
.wrap {
  background-image: url('https://placeimg.com/640/480/arch');
  height: 100%;
  background-size: cover;
}

<div class="wrap">
  <div class="content">
    <p>Content goes here</p>
  </div>
</div>

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

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