DIV+CSS例子

时间:2023-03-08 18:56:53
DIV+CSS例子

DIV水平居中+垂直居中

#main_zone{
width:1190px;
height:570px;
background-color:#fff;
margin:0 auto; /*左右居中*/
margin-top:-285px;/*垂直居中*/
margin-left:-595px;
position:absolute;
top:50%;
left:50%;/*
border:1px solid red; */
}

1.第一个例子


  1. index.css

  2. #header ,#centers ,#footer

  3. {

  4. width:1024px;

  5. margin:0 auto;

  6. clear:both;

  7. font-size:18px;

  8. line-height:68px;

  9. font-weight:bold;

  10. }

  11. #header

  12. {

  13. height:68px;

  14. border:1px solid #CCCCCC;

  15. }

  16. #centers

  17. {

  18. padding:8px 0;

  19. }

  20. #footer

  21. {

  22. border-top:1px solid #CCCCCC;

  23. background:#F2F2F2;

  24. }

  25. #centers .c_left

  26. {

  27. float:left;

  28. width:390px;

  29. border:1px solid #00CC66;

  30. background:#F7F7F7;

  31. margin-right:5px;

  32. }

  33. #centers .c_right

  34. {

  35. float:left;

  36. width:625px;

  37. border:1px solid #00CC66;

  38. background:#F7F7F7

  39. }


  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  2. <htmlxmlns="http://www.w3.org/1999/xhtml">

  3. <head>

  4. <metahttp-equiv="Content-Type"content="text/html; charset=gb2312"/>

  5. <title>css布局案例实验页面-www.divcss5.com.cn</title>

  6. <linkhref="index.css"rel="stylesheet"type="text/css"/>

  7. </head>

  8. <body>

  9. <divid="header">我是头部(上)</div>

  10. <divid="centers">

  11. <divclass="c_left">我是中的左</div>

  12. <divclass="c_right">我是中的右</div>

  13. <divclass="clear">&nbsp;</div>

  14. </div>

  15. <divid="footer">我是底部(下)</div>

  16. </body>

  17. </html>

2.第二个例子

@charset "utf-8";
/* CSS Document */
html,body,div,span,h1,h2,h3,h4,h5,h6,p,pre,a,code,em,img,small,strong,sub,sup,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;transparent}
a{color:#007bc4 /*#424242*/; text-decoration:none;}
ol,ul{list-style:none}
table{border-collapse:collapse;border-spacing:0}
body{height:100%; font:16px/18px "Microsoft Yahei", Tahoma, Helvetica, Arial, Verdana, "\5b8b\4f53", sans-serif; color:#51555C; background:#2b2b2b/*162934*/ url(../images/body_bg.gif) repeat-x}
img{border:none}
#header{width:910px; min-height:110px; padding:3px; background:#fff; margin:0 auto;-moz-border-radius:12px;-khtml-border-radius: 12px;-webkit-border-radius: 12px; border-radius:12px;}
#main{width:910px; min-height:600px; padding:3px; margin:10px auto 0 auto; background:#fff; -moz-border-radius:12px;-khtml-border-radius: 12px;-webkit-border-radius: 12px; border-radius:12px;}
#footer{width:910px;min-height:100px; padding:3px; margin:10px auto 0 auto; background:#fff;-moz-border-radius:12px;-khtml-border-radius: 12px;-webkit-border-radius: 12px; border-radius:12px;}
#footer p{ padding:10px 2px; line-height:24px; text-align:center}
#footer p a:hover{color:#51555C}
/* ----------------------------------- 表格 ----------------------------------- */
table.dataintable {
font-family: "Microsoft Yahei", Tahoma, Helvetica, Arial, Verdana, "\5b8b\4f53", sans-serif;
/*
font-family:Arial, Helvetica, sans-serif;
*/
margin-top:10px;
border-collapse:collapse;
border:1px solid #aaa;
width:100%;
}
table.dataintable th {
vertical-align:baseline;
padding:5px 15px 5px 5px;
background-color:#d5d5d5;
border:1px solid #aaa;
text-align:left;
}
table.dataintable td {
vertical-align:text-top;
padding:5px 15px 5px 5px;
background-color:#efefef;
border:1px solid #aaa;
}
/*输入框的样式类*/
.input_text{
color: #ff0000;
background-color: #FFFFFF;
border: #006699;
border-style: dashed;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
}
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css/css.css" />
</head>
<body>
<div id="header">
</div>
<div id="main">
<?php
require 'Connection.php';
// mysql_select_db("php", $con);
$sql = "SELECT * FROM think_data";
//$result = mysql_query($sql_string);
$rs = mysql_query($sql);
if (!$rs) {
exit("Error in SQL");
}
echo "<table border=\"1\"><tr>";
echo "<th>id</th>";
echo "<th>data</th></tr>";
while ($row = mysql_fetch_array($rs)) {
$id = $row['id'];
$data = $row['data'];
echo "<tr><td>$id</td>";
echo "<td>$data</td></tr>";
}
mysql_close($con);
echo "</table>";
?>
<br/>
大多数用户都不在使用更老的 Internet Explorer 版本。Web 开发者会忽略它们。而它们的功能也过时了。<br/>
Version 4.0 (发布于 1997) 的使用率不到 1% 。它对 CSS 和 DOM 的支持非常好,但不支持 XML。<br/>
Version 3.0 (发布于 1996) 的使用率不到 0.1%。<br/>
Version 2.0 (发布于 1995)。这个版本太老了,已经没有人使用它了。<br/>
Version 1.0 (发布于 1995)。还有人记得它吗?<br/>
<table class="dataintable">
<tr>
<th width="10%">标题1</th>
<th>标题2</th>
</tr>
<tr>
<td>数据1</td>
<td>数据2</td>
</tr>
</table>
<hr/>
<form>
<table>
<tr>
<th width="10%">用户名</th>
<td><input class="input_text" type="text" name="firstname" size="15"/></td>
</tr>
<tr>
<th>密码</th>
<td> <input class="input_text" type="password" name="password" size="16"/></td>
</tr>
</table>
</form>
<hr/>
<br/>
<a href="#">后台管理</a>
</div>
<div id="footer">
<p>
版权所有,翻版必究 2013<br/>
Email:umgsai@126.com<br/>
<a href="#">后台管理</a>
</p>
</div>
</body>
</html>

DIV+CSS例子650) this.width=650;" title="QQ截图20130727205117.png" src="http://img1.51cto.com/attachment/201307/205301789.png" alt="205301789.png" />

3.第三个例子

DIV+CSS例子650) this.width=650;" src="http://img1.51cto.com/attachment/201307/093121852.png" title="QQ截图20130728092939.png" alt="093121852.png" />

代码见附件。

本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/1055961