DIV 在达到一定限制后不会自动调整其高度。请参阅
以下是 HTML 代码:
<!DOCTYPE html>
<head>
<title>Gallery</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="design.css" />
</head>
<body>
<div id="wrapper">
<div id="title">
<p id="title_font">
NAVNEET<br />
KHARE
</p>
</div>
<div id="flickr">
<!-- Content will go here -->
</div>
<div class="page_header">
GALLERY
</div>
<?php
include ("navig.html");
?>
</div>
</body>
</html>
这里是 CSS:
@
charset "utf-8";
/* CSS Document */
*{margin:0px; padding:0px; border:0px; line-height: 100%; font-size: 100%;}
html {height:auto;width:auto;}
body {background-color:#000;width:100%;height:auto;}
#wrapper {position:absolute;width:870px;min-height:100%;background-color:#191919;left:50%;margin-left:-435px;height:auto;}
#title {position:absolute;left:1%;}
#title_font {color:#FFF;font-size:60px;line-height:100%;}
#navig {position:absolute;width:200px;right:-4%;top:400px;}
.nav {position:absolute;background-color:#666;height:20px;width:150px;display:block;text-decoration: none;text-align: center;color:white;
-moz-transition-property:-moz-transform 1s;
-moz-transition-duration:3s;
-moz-transition-timing-function:cubic-bezier(0, 1, 0, 1);
-o-transition-property:-moz-transform 1s;
-o-transition-duration:3s;
-o-transition-timing-function:cubic-bezier(0,1,0,1);
-webkit-transition-property:-moz-transform 1s;
-webkit-transition-duration:3s;
-webkit-transition-timing-function:cubic-bezier(0,1,0,1);
}
.nav:hover
{
background-color : #A0050A;
-moz-transform:translate(-20px,0px);
-o-transform:translate(-20px,0px);
-webkit-transform:translate(-20px,0px);
}
#front_image {position:absolute;top:150px;left:70px;padding-bottom:30px;}
#chat {position:absolute;top:150px;left:70px;padding-bottom:30px;}
#grooveshark {position:absolute;top:150px;left:70px;padding-bottom:30px;}
#comment_box {position:absolute;top:150px;left:70px;padding-bottom:30px;}
#flickr {position:absolute;top:150px;left:12px;height:600px;width:677px;background-color:white;}
#hide {position:absolute;width:577px;height:30px;background-color:#191919;top:615px;left:70px;z-index:2;}
.page_header {position:absolute;top:250px;right:2%;color:#BD060B;font-size:xx-large;text-align:center;border-style:solid;border-color:#BD060B;border-width:medium;width:150px;word-wrap:normal;word-spacing:5px;padding:2px;}
问题是,如您所见,我已将 div“flickr” 的大小设置为 600 px(高度方向),因此,我期待包装器div 相应扩展以包含所有子 div。但结果并不完全如此。我在下面附上一张图片来显示我得到的结果。我使用红色箭头来显示问题:
https://i.sstatic.net/x0W4K.jpg
如果有人能指出我的错误,那就太好了!提前谢谢大家!
The following is the HTML code :
<!DOCTYPE html>
<head>
<title>Gallery</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="design.css" />
</head>
<body>
<div id="wrapper">
<div id="title">
<p id="title_font">
NAVNEET<br />
KHARE
</p>
</div>
<div id="flickr">
<!-- Content will go here -->
</div>
<div class="page_header">
GALLERY
</div>
<?php
include ("navig.html");
?>
</div>
</body>
</html>
And here goes the CSS :
@
charset "utf-8";
/* CSS Document */
*{margin:0px; padding:0px; border:0px; line-height: 100%; font-size: 100%;}
html {height:auto;width:auto;}
body {background-color:#000;width:100%;height:auto;}
#wrapper {position:absolute;width:870px;min-height:100%;background-color:#191919;left:50%;margin-left:-435px;height:auto;}
#title {position:absolute;left:1%;}
#title_font {color:#FFF;font-size:60px;line-height:100%;}
#navig {position:absolute;width:200px;right:-4%;top:400px;}
.nav {position:absolute;background-color:#666;height:20px;width:150px;display:block;text-decoration: none;text-align: center;color:white;
-moz-transition-property:-moz-transform 1s;
-moz-transition-duration:3s;
-moz-transition-timing-function:cubic-bezier(0, 1, 0, 1);
-o-transition-property:-moz-transform 1s;
-o-transition-duration:3s;
-o-transition-timing-function:cubic-bezier(0,1,0,1);
-webkit-transition-property:-moz-transform 1s;
-webkit-transition-duration:3s;
-webkit-transition-timing-function:cubic-bezier(0,1,0,1);
}
.nav:hover
{
background-color : #A0050A;
-moz-transform:translate(-20px,0px);
-o-transform:translate(-20px,0px);
-webkit-transform:translate(-20px,0px);
}
#front_image {position:absolute;top:150px;left:70px;padding-bottom:30px;}
#chat {position:absolute;top:150px;left:70px;padding-bottom:30px;}
#grooveshark {position:absolute;top:150px;left:70px;padding-bottom:30px;}
#comment_box {position:absolute;top:150px;left:70px;padding-bottom:30px;}
#flickr {position:absolute;top:150px;left:12px;height:600px;width:677px;background-color:white;}
#hide {position:absolute;width:577px;height:30px;background-color:#191919;top:615px;left:70px;z-index:2;}
.page_header {position:absolute;top:250px;right:2%;color:#BD060B;font-size:xx-large;text-align:center;border-style:solid;border-color:#BD060B;border-width:medium;width:150px;word-wrap:normal;word-spacing:5px;padding:2px;}
The problem is, as you can see, I've made the div "flickr" to be of size of 600 px (heightwise) and thus, I was expecting the wrapper div to expand accordingly to contain all the children divs. But the result isn't quite so. I am attaching a picture below to show what is the result that I am getting. I've used a red arrow to show the problem :
https://i.sstatic.net/x0W4K.jpg
It'd be really great if someone could highlight my mistake! Thanks a bunch in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要在任何地方都使用绝对位置。使用此代码它将为您工作。
Do not use position absolute every where. Use this code It will work for you.