本文章来给大家介绍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>