html - CSS 中的动态布局

标签 html css asp.net

我在 ASP.net 中用 CSS 做了一个非常简单的布局。

HTML

<div id="header">
<h1>Header</h1>
</div>

<div id="nav">
<h1> Site
</div>

<div id="section">
<h1>Content</h1>
 </div>

<div id="footer">
Footer
</div>

CSS

#header {
    background-color:black;
    color:white;
    text-align:center;
    padding:5px;
}
#nav {
    line-height:30px;
    background-color:#eeeeee;
    height:300px;
    width:100px;
    float:left;
    padding:5px;          
}
#section {
    text-align:center;
    width:350px;
    float:left;
    padding:10px;        
}
#footer {
    background-color:black;
    color:white;
    clear:both;
    text-align:center;
   padding:5px;      
}

jsfiddle

我想要的是,如果我在 ASP.net 设计器的设计 View 中更改页脚、页眉或内容区域的大小,所有其他区域都会相应地调整自己的大小。 即任何部分的增加或减少都会对所有其他区域产生级联效应。 例如,如果我增加页脚的大小,那么内容和页眉的大小应该与页脚保持一致。 如何做到这一点?

最佳答案

所以您基本上想要响应式设计?我在你的内容周围添加了一个包装 div,当你增加它的宽度时,其他元素的宽度也会随着宽度以百分比给出而增加。更多细节请看fiddle https://jsfiddle.net/ptgcfgks/1/

<div id="wrapper">

<div id="header">
<h1>Header</h1>
</div>

<div id="nav">
<h1> Site
</div>

<div id="section">
<h1>Content</h1>
 </div>

<div id="footer">
Footer
</div>

 </div><!--wrapper-->

关于html - CSS 中的动态布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29739741/

相关文章:

html - 节号的CSS反增量

html - 如何禁用输入框中的文本?

c# - 在 C# 中更新对象时 session 对象发生变化

html - 如何将进度条嵌入到 HTML 表单中?

html - 我似乎无法获得背景图像以在 css 中呈现任何内容

javascript - 将隐藏选项卡中的 HTML5 验证事件传递给 JavaScript 函数

html - 居中 div 中被垂直滚动条覆盖的内容的右边缘

javascript - HTML 下拉菜单的自定义属性在 Chrome 中为空,在 IE 中工作正常

c# - 如何获取两个 T 类型变量之间的所有值?

jquery - 在具有较低 z-index 和部分覆盖的绝对定位 div 中检测点击?