การแก้ปัญหากรณี div หลักไม่ขยายตามความสูงของ div ย่อย ใน Firefox

CSS Code

<style type="text/css">
div.cDiv{
	margin:auto;
	width:75%;
	background-color:#EAEAEA;
	border:1px solid #999999;
}
div.lDiv{
	float:left;
	width:200px;
	background-color:#FFCC99;
	border:1px solid #999999;	
}
</style>

HTML Code

<div class="cDiv">
test test
test test

<div class="lDiv">
test<br />

test<br />
test<br />
test<br />
test<br />
test<br />
test<br />
test<br />
test<br />
test<br />

</div>

</div>

ปัญหาจะเกิดกับ Firefox การแก้ปัญหา โดยเพิ่ม

<div style="clear:both"></div>
ไว้ก่อนปิด div หลัก

HTML Code

<div class="cDiv">
test test
test test

<div class="lDiv">
test<br />

test<br />
test<br />
test<br />
test<br />
test<br />
test<br />
test<br />
test<br />
test<br />

</div>
<!--เพิ่มบรรทัดข้างล่างนี้ก่อนปิด div หลัก-->
<div style="clear:both"></div>
</div>

บทความในหมวดที่่น่าสนใจ อื่นๆ CSS Learning

31 Oct 09 ใช้งาน CSS Sprite images กับ การกำหนด CSS ของ Input form อย่างง่าย อ่าน 727 14 Feb 09 การระบุการใช้งาน css ค่าใดค่าหนึ่ง อย่างเฉพาะเจาะจง (specificity) อ่าน 649 14 Jan 10 รู้จัก property position ของ css ให้มากขึ้น ด้วย ตัวอย่าง และคำอธิบาย อ่าน 490
จำนวนผู้เยี่ยมชม 85018 คน 2010 © Copyright ninenik.com. All rights reserved.