html css floatleft,HTML/CSS float left issue

这篇博客探讨了在网页设计中遇到的一个常见问题:如何使div元素根据内部内容自动调整高度。作者提供了CSS代码示例,并详细解释了如何通过修改样式来实现内容侧并排显示且div高度自适应。内容包括#container、#header、#menu、#content和#footer等元素的样式设置,旨在创建一个响应式的页面布局。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I have been recently designing some content which needs to be side by side and have the height automatically resize, but the height doesn't resize. The div doesn't expand to the size of the items inside of it. Is there a way to allow the div to expand to the size of the elements inside of it?

CSS

* {

padding: 0px;

margin: 0px;

}

body {

font-family: 'Metrophobic', sans-serif;

background-color: #c5c5c5;

background-image: url('../images/noise.png');

}

#container {

width:900px;

background-color: #dbdbdb;

margin-top: 20px;

margin-left: auto;

margin-right: auto;

margin-bottom: 20px;

box-shadow: 0px 0px 5px black;

}

.center_align {

display: inline-block;

margin-left: auto;

margin-right: auto;

}

#header {

height:80px;

font-size: 60px;

padding: 10px;

text-align: center;

}

#menu {

width:900px;

height:50px;

margin-top: 10px;

margin-bottom: 10px;

background-color: #cacaca;

}

.menu_link {

width:224px;

height:50px;

text-align: center;

font-size: 35px;

float: left;

opacity: 0.3;

background-color: #cacaca;

}

.menu_divider {

width: 1px;

height: 50px;

background-color: #dbdbdb;

float:left;

}

#content {

width: 900px;

height: auto;

padding: 10px;

font-size: 20px;

height: auto;

}

.line_container {

margin-top:5px;

margin-bottom:5px;

}

#footer {

width:900px;

height:22px;

padding-top:2px;

text-align: center;

font-size: 14px;

color:black;

}

a:link {

color:black;

text-decoration: none;

}

a:visited {

color:black;

text-decoration: none;

}

a:hover {

color:black;

text-decoration: none;

}

a:active {

color:black;

text-decoration: none;

}

a.link:link {

color:#21525e;

}

a.link:visited {

color:#21525e;

}

a.link:hover {

color:#307f91;

text-decoration: underline;

}

a.link:active {

color:#307f91;

text-decoration: underline;

}

HTML

Home

.icon {

width:100px;

height:100px;

border: 3px solid white;

border-radius:25px;

margin-left:10px;

margin-right:10px;

background-position: center center;

background-size: 100px 100px;

}

I'm a freelance Web, Iphone, and Game developer.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值