我想創建簡單的HTML。我想創建3個div。html中心div總是在中間,其他兩個動態
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="generator" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="stylesheet" type="text/css" href="style.css" media="screen">
<title>My Site</title>
</head>
<body>
<div id="top_left">
</div>
<div id="top_center">
</div>
<div id="top_right">
</div>
</body>
</html>
中心div是固定的大小,總是在中間。但第一個和第三個div是動態的。如何做到這一點。
CSS
#top_left {
background-image: url(images/pikacom_01.gif);
background-repeat: repeat-x;
background-position: left;
height: 85px;
}
#top_center {
background-image: url(images/pikacom_02.gif);
background-repeat: no-repeat;
background-position: center;
width: 1024px;
margin: 0 auto;
height: 85px;
}
#top_right {
background-image: url(images/pikacom_03.gif);
background-repeat: repeat-x;
background-position: right;
}
你能預先指定的寬度和'#top_right'和'#top_left'的高度或在這些動態調整基於內容? –
我假設高度爲85px(請參閱'#top_left')。由於它被稱爲'top_ ...',它可能是某種標題。至於寬度,請參閱我的答案,左欄和右欄真正靈活。 – Paul
#top_left和#top_right是動態的,取決於屏幕的大小。中心只有1024像素寬度... – senzacionale