当前位置:编程学习 > html/css >>

css 背景图水平、垂直居中方法

核心代码

 代码如下 复制代码

background:url(images/bg.gif) no-repeat 50% 50%;
background:url(images/bg.gif) no-repeat center center;

实例

 代码如下 复制代码

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>body背景上下左右居中</title>

<style type=”text/css”>
<!–
*{ padding:0; margin:0;}
html{ height:100%;}
body {
background: url(01300000081395124875325123568.jpg) 50% no-repeat;
height:100%;
}
–>
</style></head>

<body>
</body>
</html>

补充:Css教程,CSS入门 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,