简体   繁体   English

将div设置为固定在相对位置上的位置

[英]set div to position fixed on the relative location

Is it possible to make a div fixed on the location where it is drawn (it's standard ' static / relative ' location)? 是否可以将div fixed在绘制位置(它是标准的“ static / relative ”位置)?

So I want div .one , .three and .four to be fixed in the location where it is drawn initially. 因此,我希望将div .one.three.four固定在最初绘制的位置。 So that it doesn't scroll. 这样它就不会滚动。 https://jsfiddle.net/sor8hntk/2/ https://jsfiddle.net/sor8hntk/2/

Yes! 是! https://jsfiddle.net/sor8hntk/7/ https://jsfiddle.net/sor8hntk/7/

body {
  margin-top:40px;
}

.one {
  float:left;
  background-color:green;
  width:33%;
  height:50px;
  position: fixed;
}
.two {
  float:left;
  background-color:red;
  width:33%;
  height:500px;
  left: 33%;
  position: absolute;
}

.three {
  float:left;
  background-color:blue;
  width:33%;
  height:50px;
  position: fixed;
  left: 66%;
}

.four {
  width:33%;
  background-color:purple;
  height:10px;
  position: fixed;
}

.five {
  width:100%;
  background-color:pink;
  margin-top: 10px;
}

.six {
  width:100%;
  height:10px;
  background-color:yellow;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM