css 如何将背景图片固定在某一个地方

时间:2016-07-30
在css设计中,我们有时候需要将背景图片固定在页面的某一个地方,不管页面滚动条滚动到哪里,都固定不动,其实实现起来很简单,我们只需要将background设置为fixed即可。

css实现将背景图片固定,源码如下:

<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
body{
  margin:0;
}
div {
  height: 1000px;
  width: 100%;
  background: transparent
    url(http://www.manongjc.com/Public/images/logo.gif)
    no-repeat fixed 0 0;
}
</style>
</head>
<body>
  <div></div>
</body>
</html>

在线运行