我不確定我是否可以按照我的方式使用花車。如果我錯誤地完成了任何提示,請多多包涵。這是使用多個CSS浮動的正確方法嗎?
注意
我打算在內部樣式表遷移到外部樣式表一旦我已經完成了佈局,以及元數據的賽區等
<!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" />
<meta http-equiv="Content-Language" content="en-us" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="author" content="" />
<link rel="icon" type="image/png" href="" />
<link rel="stylesheet" type="text/css" media="all" href="" />
<style type="text/css" media="all">
* {
margin: 0px;
padding: 0px;
}
body {
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 1em;
font-style: normal;
font-weight: normal;
color: #000000;
}
#wrapper {
width: 600px;
margin: 0px auto;
}
#propertydesc {
background-color: #e5e8ed;
padding: 10px;
}
#content {
float: left;
}
#propertyinfo {
float: right;
}
.cls {
clear: both;
}
#agent {
float: right;
}
</style>
<title>Sample Template</title>
</head>
<body>
<div id="wrapper">
<div id="logo"><img src="logo.png" width="100" height="157" /></div>
<div id="propertydesc">property description</div>
<div id="hero">hero</div>
<div id="content"><p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p></div>
<div id="propertyinfo">property info</div>
<div class="cls"></div>
<div id="agent">agent</div>
<div class="cls"></div>
<div class="contact">contact</div>
</body>
</html>
編輯
我更新了我的代碼,以幫助解決代理div標籤出現在屬性信息div標籤下方的問題,但我不確定它是否合作rrect。
<!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" />
<meta http-equiv="Content-Language" content="en-us" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="author" content="" />
<link rel="icon" type="image/png" href="" />
<link rel="stylesheet" type="text/css" media="all" href="" />
<style type="text/css" media="all">
* {
margin: 0px;
padding: 0px;
}
body {
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 1em;
font-style: normal;
font-weight: normal;
color: #000000;
}
#wrapper {
width: 600px;
margin: 0px auto;
}
#propertydesc {
background-color: #e5e8ed;
padding: 10px;
}
#content {
float: left;
width: 200px;
}
p {
margin-top: 10px;
margin-bottom: 10px;
}
#propertyinfo {
/* float: right; */
margin-left: 400px;
background-color: #e5e8ed;
width: 200px;
}
#agent {
float: right;
background-color: #e5e8ed;
width: 200px;
}
.cls {
clear: both;
}
</style>
<title>Sample Template</title>
</head>
<body>
<div id="wrapper">
<div id="logo"><img src="logo.png" width="100" height="157" /></div>
<div id="propertydesc">property description</div>
<div id="hero">hero</div>
<div id="content">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<div id="propertyinfo">property info</div>
<div id="agent">agent</div>
<div class="cls"></div>
<div class="contact">contact</div>
</body>
</html>
似乎沒什麼問題,你有任何具體問題? –
沒有什麼特別錯。在這種情況下浮動#agent是無用的。你也可以在#content和#propertyinfo上使用float:left。瀏覽器會將它們並排放置。另一種方法是給#propertyinfo一個等於內容寬度的餘量。這樣你就不必明確指定元素的寬度(主要用於流體設計) – Gerben
@paulGraffix&Gerben - 請參閱我對Skylar的評論 – PeanutsMonkey