作者:趣趣虎 来源:www.ququhu.com 时间:2007-09-05
很多时候明明感觉应该自适应的效果,
可是在不同浏览器里却取得不同的结果,
这个时候最令人伤神。
有时利用“相对位置”和“绝对位置”方法来确定DIV的方位,
也是个很不错的想法,
至于如何使用,使用那种方法,
还是要看个人习惯以及网页整体要求。
来看看下面的方法,从中会掌握自适应的一种好方法。
XHTML
CSS
效果参照:http://www.pmob.co.uk/temp/2col_main.htm
可是在不同浏览器里却取得不同的结果,
这个时候最令人伤神。
有时利用“相对位置”和“绝对位置”方法来确定DIV的方位,
也是个很不错的想法,
至于如何使用,使用那种方法,
还是要看个人习惯以及网页整体要求。
来看看下面的方法,从中会掌握自适应的一种好方法。
XHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="2columngray.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="mainheader">
<div class="blank2"></div>
<!-- for decoration only -->
</div>
<div id="header">
<p>Header content goes here</p>
<p><a href="2col_left.htm">Left </a>column Longest</p>
<p><a href="2col_right.htm">Right</a> column Longest</p>
<p><a href="2col_main.htm">No</a> column longest</p>
<p><a href="http://www.pmob.co.uk/temp/3colfixedtest_4.htm">Back</a> to main
3 column demo</p>
</div>
<div id="mainnav">
<p>Navigation</p>
</div>
<div id="sidebar">
<p>Sidebar content goes here : Sidebar content goes here : Sidebar content
goes here : Sidebar content goes here : Sidebar content goes here : Sidebar
content goes here : Sidebar content goes here : Sidebar content goes here
: Sidebar content goes here : Sidebar content goes here : Sidebar content
goes here : Sidebar content goes here : </p>
</div>
<div id="content">
<p>Footer stays at the bottom of the window unless the content is longer then
it stays at the bottom of the document.</p>
<p>Footer stays at the bottom of the window unless the content is longer then
it stays at the bottom of the document.</p>
</div>
<div id="clearfooter"></div>
<!-- to clear footer -->
<div id="footer">
<div class="divider1"></div>
<div class="blank"></div>
<!-- for decoration only -->
<p>Footer Content</p>
</div>
</div>
</body>
</html>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="2columngray.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="mainheader">
<div class="blank2"></div>
<!-- for decoration only -->
</div>
<div id="header">
<p>Header content goes here</p>
<p><a href="2col_left.htm">Left </a>column Longest</p>
<p><a href="2col_right.htm">Right</a> column Longest</p>
<p><a href="2col_main.htm">No</a> column longest</p>
<p><a href="http://www.pmob.co.uk/temp/3colfixedtest_4.htm">Back</a> to main
3 column demo</p>
</div>
<div id="mainnav">
<p>Navigation</p>
</div>
<div id="sidebar">
<p>Sidebar content goes here : Sidebar content goes here : Sidebar content
goes here : Sidebar content goes here : Sidebar content goes here : Sidebar
content goes here : Sidebar content goes here : Sidebar content goes here
: Sidebar content goes here : Sidebar content goes here : Sidebar content
goes here : Sidebar content goes here : </p>
</div>
<div id="content">
<p>Footer stays at the bottom of the window unless the content is longer then
it stays at the bottom of the document.</p>
<p>Footer stays at the bottom of the window unless the content is longer then
it stays at the bottom of the document.</p>
</div>
<div id="clearfooter"></div>
<!-- to clear footer -->
<div id="footer">
<div class="divider1"></div>
<div class="blank"></div>
<!-- for decoration only -->
<p>Footer Content</p>
</div>
</div>
</body>
</html>
CSS
/* commented backslash hack v2 \*/
html, body{height:100%;}
/* end hack */
html,body {
margin: 0;
padding: 0;
}
body {
font: x-small arial, hevetica, sans-serif;
text-align: center;
color: #505367;
background-color: #e0e0e0;
}
#container {
margin-left:auto;
margin-right:auto;
width: 730px;
min-height:100%;
text-align: left;
background: #CEE0E1 url(images/toddbg.gif) repeat-y right top;
border-left: 1px solid #a1a1a1;
border-right: 1px solid #a1a1a1;
position:relative;
}
/* commented backslash hack v2 \*/
* html #container {height:100%;}
* html #container {width:732px;w\idth:730px;}
* html body{font-size:xx-small;f\ont-size:x-small}
/* end hack */
#mainheader {
position:absolute;
left:0;top:0;
height: 160px;
width:100%;
background-color: #fff;
border-bottom: 1px solid #e6e6e6;
z-index:1;
}
#header {
height: 125px;
width:100%;
background-color: #D1DCE9;
margin: 0px 0px 5px 0px;
border-top: 1px solid #e6e6e6;
border-bottom: 1px solid #e6e6e6;
position:relative;
z-index:2;
overflow:hidden;
}
* html #mainheader {height:161px;he\ight:160px}
* html #header {height:127px;he\ight:127px}
#mainnav {
width:100%;
height: 20px;
background-color: #f5f5f5;
border-top: 1px solid #e6e6e6;
border-bottom: 1px solid #e6e6e6;
position:relative;
z-index:2;
}
* html #mainnav{height:22px;he\ight:20px}
#sidebar {
float: right;
width: 170px;
padding:5px 0 ;
}
#content {
width: 553px;
padding:5px 0 ;
}
#content p, #sidebar p, #mainnav p, #header p,#footer p {margin:0 5px 5px 5px}
#footer{
position:absolute;
bottom:0;
width:100%;
height: 24px;
background-color: #f5f5f5;
border-top: 1px solid #e9e9e9;
}
#footer p {margin:0;padding:0}
* html #footer {height:25px;he\ight:24px;}
.divider1 {
width:100%;
height:5px;
overflow:hidden;
background:#fff;
position:relative;
border-bottom: 1px solid #e6e6e6;
}
#clearfooter {height:27px;width:100%;clear:both}
.blank , .blank2 {
position:absolute;
left:547px;
width:7px;
height:0px;
overflow:hidden;
border-top:1px solid #fff;
}
.blank {top:-1px;}
.blank2 {bottom:-1px;border-top:1px solid #fff;
}
html, body{height:100%;}
/* end hack */
html,body {
margin: 0;
padding: 0;
}
body {
font: x-small arial, hevetica, sans-serif;
text-align: center;
color: #505367;
background-color: #e0e0e0;
}
#container {
margin-left:auto;
margin-right:auto;
width: 730px;
min-height:100%;
text-align: left;
background: #CEE0E1 url(images/toddbg.gif) repeat-y right top;
border-left: 1px solid #a1a1a1;
border-right: 1px solid #a1a1a1;
position:relative;
}
/* commented backslash hack v2 \*/
* html #container {height:100%;}
* html #container {width:732px;w\idth:730px;}
* html body{font-size:xx-small;f\ont-size:x-small}
/* end hack */
#mainheader {
position:absolute;
left:0;top:0;
height: 160px;
width:100%;
background-color: #fff;
border-bottom: 1px solid #e6e6e6;
z-index:1;
}
#header {
height: 125px;
width:100%;
background-color: #D1DCE9;
margin: 0px 0px 5px 0px;
border-top: 1px solid #e6e6e6;
border-bottom: 1px solid #e6e6e6;
position:relative;
z-index:2;
overflow:hidden;
}
* html #mainheader {height:161px;he\ight:160px}
* html #header {height:127px;he\ight:127px}
#mainnav {
width:100%;
height: 20px;
background-color: #f5f5f5;
border-top: 1px solid #e6e6e6;
border-bottom: 1px solid #e6e6e6;
position:relative;
z-index:2;
}
* html #mainnav{height:22px;he\ight:20px}
#sidebar {
float: right;
width: 170px;
padding:5px 0 ;
}
#content {
width: 553px;
padding:5px 0 ;
}
#content p, #sidebar p, #mainnav p, #header p,#footer p {margin:0 5px 5px 5px}
#footer{
position:absolute;
bottom:0;
width:100%;
height: 24px;
background-color: #f5f5f5;
border-top: 1px solid #e9e9e9;
}
#footer p {margin:0;padding:0}
* html #footer {height:25px;he\ight:24px;}
.divider1 {
width:100%;
height:5px;
overflow:hidden;
background:#fff;
position:relative;
border-bottom: 1px solid #e6e6e6;
}
#clearfooter {height:27px;width:100%;clear:both}
.blank , .blank2 {
position:absolute;
left:547px;
width:7px;
height:0px;
overflow:hidden;
border-top:1px solid #fff;
}
.blank {top:-1px;}
.blank2 {bottom:-1px;border-top:1px solid #fff;
}
效果参照:http://www.pmob.co.uk/temp/2col_main.htm
文章关键字:解决方案 适应 页面 采用 content goes here html Sidebar
上一篇:关于box(盒模式)的一系列问题 下一篇:CSS入门教程
165 * 70 广告位招租
联系QQ:349881211
联系QQ:349881211
165 * 60 广告位招租
联系QQ:349881211
联系QQ:349881211
网友发表评论:
热点文章
·CSS应用小技巧十四例
·用CSS缩写给你的网站加速
·CSS 样式切换
·CSS光标属性一览表
·利用CSS改善网站可访问性
·收藏几个好看的button样式
·CSS中的滑动门技术
·CSS实例教程
·同一个页面用多个id有什么影响
·CSS入门教程之CSS的语法
·CSS的超级技巧大放送
·关于box(盒模式)的一系列问题
·用CSS缩写给你的网站加速
·CSS 样式切换
·CSS光标属性一览表
·利用CSS改善网站可访问性
·收藏几个好看的button样式
·CSS中的滑动门技术
·CSS实例教程
·同一个页面用多个id有什么影响
·CSS入门教程之CSS的语法
·CSS的超级技巧大放送
·关于box(盒模式)的一系列问题
相关文章
·关于box(盒模式)的一系列问题
·CSS入门教程
·CSS的超级技巧大放送
·CSS入门教程之CSS的语法
·同一个页面用多个id有什么影响
·CSS实例教程
·CSS中的滑动门技术
·收藏几个好看的button样式
·利用CSS改善网站可访问性
·CSS光标属性一览表
·CSS 样式切换
·用CSS缩写给你的网站加速
·CSS入门教程
·CSS的超级技巧大放送
·CSS入门教程之CSS的语法
·同一个页面用多个id有什么影响
·CSS实例教程
·CSS中的滑动门技术
·收藏几个好看的button样式
·利用CSS改善网站可访问性
·CSS光标属性一览表
·CSS 样式切换
·用CSS缩写给你的网站加速
相关连接
相关连接
图片连接


