CSS float高度问题

d945332077 d945332077 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple Fixed Width Rounded Corner Box</title>
<style type="text/css">
<!--
/* pretty stuff
================================== */
body {
font: 62.5%/1.6 "Gill Sans", Futura, "Lucida Grande", Geneva, sans-serif;
color: #666;
background: #fff;

}

h2 {
font-size: 2.2em;
font-weight: normal;
line-height: 1;
color: #94b767;
margin: 0;
}

.box {
font-size: 2em;
}
.box2 {
font-size: 2em;
}

/* rounded corner box
================================== */

.box {
margin-top:10px;
width: 418px;
background: #effce7 url(images/bottom.gif) no-repeat left bottom;
border:1px solid red;
}

.box h2 {
background: url(images/top.gif) no-repeat left top;
}

.box h2 {
padding: 10px 20px 0 20px;
}

.box p {
padding: 0 20px 10px 20px;
margin-bottom:0;
}
/*================================== */

.box2 {

float:right;现在右边那个DIV的高度正常,一旦将这里改成了float:left;右边那个div立即就增加了高度,麻烦帮我看哈是为什么。(右边那个也就是box那个DIV)
width: 418px;
background: #effce7 url(images/bottom.gif) no-repeat left bottom;
}

.box2 h2 {
background: url(images/top.gif) no-repeat left top;
}

.box2 h2 {
padding: 10px 20px 0 20px;
}

.box2 p {
margin-bottom:0;
padding: 0 20px 10px 20px;
}

-->
</style>
</head>

<body>

<div class="box2">
<h2>Lorem Ipsum2</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin venenatis turpis ut quam. In dolor. Nam ultrices nisl sollicitudin sapien. Ut lacinia aliquet ante.</p>
</div>

<div class="box">
<h2>Lorem Ipsum</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin venenatis turpis ut quam. In dolor. Nam ultrices nisl sollicitudin sapien. Ut lacinia aliquet ante.</p>
</div>

</body>
</html>
...全文

相关推荐

评论 13
收藏 已收藏
分享
返回顶部
d945332077
CSS 61,116 成员 60,701 内容