HTML5 wrapper 只包装 Header(使用边框)

标签 html css wrapper

我使用边框来确定我的包装器只包装了我的页眉,我很困惑为什么......我想包装页眉,一直到页脚......任何人都有任何指示?

我看到很多文章说要指定宽度,如果不指定高度也设置为自动,对吗?

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="index.css" />
    <title>Personal Transportation/Errands Services</title>
</head>

<body>
<header>
    <div id="headleft">
        <img src="images/new logo flattened.jpg" />
    </div>
    <div id="headright">
        (717)***-****
            <br />
        ********@yahoo.com
    </div>
</header>

    <nav>
        <a href="index.html">Home</a>
        <a href="contact.html">Contact</a>
    </nav>

    <article>
        Test
    </article>

    <aside>
        <img src="images/car 1.png" id="car" />
    </aside>

    <footer>
        Ftest
    </footer>
</body>
</html>

/* Makeshift CSS Reset */
    {
    margin: 0;
    padding: 0;
    }

    /* Tell the browser to render HTML 5 elements as block */
    footer, header, aside, nav, article {
    display: block;
    }

body{
width:940px;
height: 100%;
margin:0 auto;
border-style: solid;
border-width: 3px;
}

header {
background-color: #1a8cff;
}

nav {
width: 100%;
float: left;
text-align: right;
background-color: #ff7f00;
font-family: bold 'Oswald', sans-serif;
color: #ffffff;
letter-spacing: 1px;
}

a {
text-decoration: none;
}

/* unvisited link */
a:link {
color: #FFFFFF;
}

/* visited link */
a:visited {
color: #FFFFFF;
}

/* mouse over link */
a:hover {
color: #FFFF00;
}

/* selected link */
a:active {
color: #FFFF00;
}

#headleft {
display:inline;
background-color: #1a8cff;
width: 100%;
}

#headright {
height: 87px;
padding-top: 37.5px;
vertical-align: middle;
display: inline;
float: right;
background-color: #1a8cff;
border-style: solid;
border-width: 3px;
}

body {
margin: 0 auto;
width: 1000px;
font: 13px/22px Helvetica, Arial, sans-serif;
background-color: white;
background-size: 100%;
}

article{
float: left;
}

aside{
float: right;
}

footer{
float:left;
background-color: #1a8cff;
width: 100%;
}

最佳答案

您需要清除 float 元素,您可以使用 clearfix 或将空的 div 设置为 clear:both

FIDDLE

您还可以在 body 中使用一个包装器来包装页面上的每个元素并将其设置为 overflow: hidden

ALT FIDDLE

关于HTML5 wrapper 只包装 Header(使用边框),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26579961/

相关文章:

用于构建具有 C++ 后端的 GUI 的 Java 与 C++

javascript - 是否可以从页面级脚本调用书签中定义的函数?

html - hpricot 将属性添加到 HTML 标记?

html - css3 圆形聊天气泡,右 'arrow' 和边框

javascript - 放置一个 div 作为 :after of another

java - 包装第三方库时包装异常

html - 在图像标签中复制 background-img 属性

javascript - 为什么我的两个 div 总是紧挨着?

html - 将 'html' 和 'body' 元素的大小固定为屏幕的大小

html - css 动画不响应 span :nth-child