Css全宽问题 [英] Css full width question

查看:133
本文介绍了Css全宽问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为一个页面生成css我在建设在Adobe Fireworks Cs5和我想知道我如何可以设置我的标题和其他divs.I将显示css代码到标题部分的全宽。

I have generated css for a page i am building in Adobe Fireworks Cs5 and i am wondering how i can set the full width for my header and other divs.I will show the css code up to the header section.

@charset "utf-8";

body {
 background-color: #fff;
 font-size: 62.5%;
 margin: 0;
 padding: 0;
}
body * {
 font-size: 100%;
}
h1, h2, h3, h4, h5, h6 {
 font-weight: normal;
}
p {
 margin-bottom: 1.1em;
 margin-top: 0;
}
#main p.lastNode {
 margin-bottom: 0;
}
a:link img, a:visited img {
 border: none;
}
div.clearFloat {
 clear: both;
 font-size: 0;
 height: 0;
 line-height: 0px;
}
li.clearFloat {
 clear: both;
}
ul.symbolList {
 display: inline;
 float: left;
 list-style-type: none;
 margin: 0;
 padding: 0;
}
.AbsWrap {
 position: relative;
 width: 100%;
}
.rowWrap {
 width: 100%;
}
#main {
 margin: 0 auto 0 0;
 width: 960px;
}
#Div {
    position:absolute;
 margin-left: 0px;
 margin-top: 0px;
 display: inline;
 float: left;
 margin-bottom: 0;
 background-color: #333;
 width: 960px;
 margin-left:-480px;
    left:50%;
 padding-top: 0px;
 height: 849px;
}
html > body #Div {
 height: auto;
 min-height: 850px;
}
#Div2 {
   /* This is the Header*/
 margin-left: 0px;
 margin-top: 0px;
 display: inline;
 float: left;
 margin-bottom: 0;
 background-color: #300;
 width: 960px;
 padding-top: 0px;
 height: 99px;
}
html > body #Div2 {
 height: auto;
 min-height: 100px;
}


推荐答案

div,如果它们不包含在一些其他元素内或以其他方式定位,则总是全宽。在你的case,它看起来像你绝对定位一些元素,而没有设置宽度。这可能会导致div崩溃,除非它有内容。此外,如果使用percent设置宽度,请记住它是父级的百分比。父项是否设置为任何单位大小本身?

Block level elements, such as div, are always full width if they are not contained inside some other element or positioned otherwise. In your case, it looks as if you absolutely positioned some elements without setting a width. This may cause the div to collapse onto itself unless it has content. Also, if you use percent to set a width, always remember that it's a percent of the parent. Is the parent set to any unit size itself?

这篇关于Css全宽问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆