html 页面全屏设置背景图,如何去掉滚动条

如题所述

首先~还是给body设置背景~
然后再body里面加一个层~~
把这个层定义成你想要的“body”的大小 - -
~其实页面你能看到的地方。都是在body里的。。
----------------------------

<!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>无标题文档</title>
<style>
*{margin:0 auto; padding:0 auto;}
body { background-color:#000}
#container { width:800px; height:600px;background-color:#FFF} /*这里高度是不用设的,只是DIV里面没内容,我就设了下高度,好看效果哈*/
</style>
</head>

<body>
<div id="container">
</div>
</body>
</html>
温馨提示:内容为网友见解,仅供参考
第1个回答  2018-05-04
body{
  overflow: hidden;
  font-family: "微软雅黑";
  margin: 0; 
  padding: 0;
  position: relative;
  width: auto;
  height:auto;
  background:url("./img/timg.jpg") no-repeat;
  background-position: center;
  background-size: 100%;
}

相似回答