如何在视图中保留内容?

时间:2016-10-30 10:26:44

标签: html css3

我目前有一个容器和一个内容。

如何将内容保留在浏览器中?

以下是代码:

      <h1>
        Content inside
      </h1>

2 个答案:

答案 0 :(得分:0)

只需添加到body

即可
overflow: hidden;

并确保使用

box-sizing: border-box;

或删除width:100%;

box-sizing:border-box; 修复了填充100%宽度的问题 - 将填充放置在元素的框模型中。

&#13;
&#13;
*{margin:0;box-sizing:border-box;}
html,body{height:100%;font:14px/1.4 sans-serif;}

body{overflow:hidden;}

#container {
  background-color: white;
  min-height: 100%;
  padding: 30px; 
}
&#13;
  <div id="container">
      <h1>
        Content inside
      </h1>
      <div>
        I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. I currently have a container and a content inside. When the browser gets minimized, the content inside overflows, and the scroll bars appear. 
      </div>
  </div>
&#13;
&#13;
&#13;

<强> jsBin demo

答案 1 :(得分:-1)

你可以试试这个

#container {
  background-color: white;
  min-height: 100%;
  padding: 30px;
  width: 100%;
  box-sizing: border-box;
}

.clear_ {
    clear: both;
    width: 100%;
    height: 1px;
}


<div id="container">
      <h1>
        Content inside
      </h1>
      <div>
      your text here
      </div>
<div class="clear_"></div>
  </div>

我希望这个帮助