我是设计版面的新手。
我已经制作了这个布局,但是当我在其中添加更多文本或任何元素时,它不会扩展容器内的内部div。请好好纠正我的CSS。
这是我布局的CSS
@charset "utf-8"; /* CSS Document */ @media only screen { #fullPage { width:1100px; height:850px; position:relative; margin:auto; background-color:#999999; } header { width:100%; height:200px; position:relative; background-color:red; } header > nav { width:50%; height:50%; margin:auto; position:relative; background-color:lime; } #mobile { display:none; background-color:orange; } #fullPage > section { width:100%; height:100%; min-height:500px; position:relative; background-color:yellow; } section > aside, section > section { width:500px; height:100%; position:absolute; top:0px; left:0px; background-color:pink; } section > aside~aside { width:100px; left:1000px; } section > section { left:500px; background-color:blue; } footer { width:100%; height:150px; position:relative; background-color:red; } } @media only screen and (max-width:1024px) and (min-width:801px) { #fullPage { width:1000px; } header > nav { background-color:pink; } section > aside~aside { display:none; } } @media only print { } @media only screen and (max-width:800px) { #fullPage { width:640px; height:1350px; } header { background-color:lime; } header > nav { width:75%; height:50%; margin:auto; } #mobile { display:block; } #desktop { display:none; } #fullPage > section { height:1000px; } section > aside, section > section { width:100%; height:50%; position:relative; left:0px; } section > aside~aside { display:none; } }
这是我的HTML
<div id="fullPage">
<header>
<nav id="desktop">DESKTOP</nav>
<nav id="mobile">MOBILE</nav>
</header>
<section>
<aside>menu-1</aside>
<section>Lorem Ipsum is Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.There are many variations of passages of Lorem Ipsum available, but the majority</section>
<aside>menu-2</aside>
</section>
<footer>footer-1</footer>
</div>
答案 0 :(得分:1)
你的内部“部分”元素有位置:绝对;因此它不会“拉伸”它包含元素的高度(设置为500px)。 你真正想做的不是使用position:absolute;因此,使用“浮动”方法可以更加动态地提升元素的高度。
我建议遵循这个: http://webdesign.about.com/od/csstutorials/ss/css_layout_sbs.htm