html - Div 布局问题 - 无法让标题随页面放大/缩小

标签 html css

我目前正在设计一个简单的网络应用程序,供屏幕尺寸为 1024x768 到 1600x1200 显示器的各种用户使用。

这是我到目前为止所取得的成就:http://jsfiddle.net/AdyQ5/

不幸的是,页面的顶部似乎溢出到了正文中。知道如何解决这个问题吗?

这是我的代码:

CSS

#header {
    width: 100%;
    height: 20%;
    min-height: 20%;
    max-height: 20%;
    position: fixed;
    border-bottom: 1px solid #e8e8e8;
}
#main {
    width: 100%;
    height: 80%;
    min-height: 80%;
    max-height: 80%;
    position: fixed;
    overflow-y: scroll;
    overflow-x: none;
    top: 20%;
}
#text_header {
    font-size: 1em;
    font-weight: bold;
}
body {
    margin: 0px;
    font-family: Arial, Helvetica, sans-serif;
}
#title, #message {
    width: 95%;
}
.container {
    padding: 10px;
}
label {
    font-size: 0.8em;
}

HTML

<div id="header">
  <div class="container"> 
  <span id="text_header">Virtual Idea Wall</span> 
    <p>
        <label for="title">Please give your idea a title</label>
        <br />
        <input type="text" id="title" name="title"/>
    </p>
    <p>
        <label for="message">Please provide details of your idea</label>
        <br>
        <input type="text" id="message" name="message"/>
    </p>
    <p>
        <input type="submit" id="sendmessage">
    </p>
    </input>
  </div>
</div>

<div id="main">
  <div class="container">
    <div id="chat"></div>
  </div>
</div>

最佳答案

您可以简单地删除或调整 <p> 上的默认页边距标签。

p { margin:0; }

Updated Fiddle

要真正做到动态,您需要从标题中删除所有高度属性:

#header {
    width: 100%;
    position: fixed;
    border-bottom: 1px solid #e8e8e8;
}

Additional demo

关于html - Div 布局问题 - 无法让标题随页面放大/缩小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17821092/

相关文章:

html - CSS -moz-appearance 不适用于单选按钮

css - 一个 div 可以用基于像素的边距填充整个视口(viewport),而不使用 CSS3 calc 属性吗?

html - div 在移动 View 上无法正确显示

javascript - 准确设置文本位置

javascript - 更改模板文字内文本的颜色

css - 使 IE9 CSS nth-child 规则在 IE8 上工作

css - 包装器上的跨浏览器对齐问题

jquery - 将魔术线宽度设置为 anchor 而不是列表项

html - HTML iframe可以继承css和javascript数据吗

css - 在不影响布局的情况下将 glyphicon 添加到不是使用 bootstrap 创建的网页