css - 在html中调整div

标签 css html

我是 html 新手。我想做一个简单的布局设计如下:

-------------------------------------
                                    |
-------------------------------------
    |                           |   |
    |                           |   |
    |                           |   |
    |                           |   |
    |---------------------------|   |
____|_________footer____________|___|

但是我的页脚在左右菜单之间没有调整。在左右菜单下方。

下面是我的html代码:

<html>
<head>
<style>
#container {
    height: 100%;
    width: 100%;
    background-color: aqua;
    position: relative;
}

#header {
    height: 5%;
    background-color: #FFA500;
}

#leftmenu {
    background-color: #FFD700;
    height: 90%;
    width: 20%;
    float: left;
}

#rightmenu {
    background-color: #FFD700;
    height: 90%;
    width: 10%;
    float: left;
}

#content {
    style ="background-color: #EEEE12;
    height: 85%;
    width: 70%;
    float: left;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><tiles:insertAttribute name="title" ignore="true"></tiles:insertAttribute>
</title>
</head>
<body>
    <div id="container" class=".container">

        <div id="header" class=".header">
            <h1>Main Title of Web Page</h1>
        </div>

        <div id="leftmenu" class=".leftmenu">
            <b>Menu</b><br> HTML<br> CSS<br> JavaScript
        </div>

        <div id="content" class=".content">Content goes here</div>

        <div id="rightmenu" class=".rightmenu">
            <b>DashBoard</b><br> Recent<br> Saved Search
        </div>

        <div id="footer"
            style="background-color: #FFA500; clear: both; text-align: center;">
            Copyright © W3Schools.com</div>

    </div>


</body>
</html>

最佳答案

所以我在这里所做的是创建一个中间 div。其中包含您的内容和页脚。

你的中间 div 有一个相对位置,我绝对将你的页脚定位在底部。

注意,中间的 div 需要一个高度才能工作。不过这应该不是问题!

如果您还需要什么,请告诉我!

<div id="middle"> 
<div id="content" class=".content">Content goes here</div>
<div id="footer" style="background-color: #FFA500; clear: both; text-align: center;">
Copyright © W3Schools.com
</div>
</div>
</div>

#middle {float: left; width: 70%; height: 80px; position: relative;}
#footer {bottom: 0px; position: absolute; width: 100%}

这是一个 fiddle 示例!

http://jsfiddle.net/LmVKD/

关于css - 在html中调整div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22260606/

相关文章:

css - 中间对齐差异 : Material-icons vs Font-Awesome

javascript - JS、HTML5 - 在 Canvas 上添加文本输入值作为 fillText

javascript - 如何正确地将单击的按钮属性值传递给表单提交事件?

html - 我怎样才能使表格的单元格更大?

javascript - 移动到子菜单后使菜单保持悬停状态

javascript - 如何使用 CSS3 animate 上下移动 div 的背景图像?

html - 跨同一浏览器的 CSS/HTML 兼容性问题

html - 悬停时更改标签和输入元素的字体大小 - 使用 CSS 的 HTML

html - 文本退出 div 并更改另一个 div 的大小

php - 如果我使用子域,图像的 url