css 背景圖水平、垂直置中方法

來源:互聯網
上載者:User

核心代碼

 代碼如下 複製代碼

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>

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.