Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 如何将div定位在其不存在的位置';调整浏览器大小时,是否不移出页面,但会更改位置?_Css - Fatal编程技术网

Css 如何将div定位在其不存在的位置';调整浏览器大小时,是否不移出页面,但会更改位置?

Css 如何将div定位在其不存在的位置';调整浏览器大小时,是否不移出页面,但会更改位置?,css,Css,我希望调整浏览器大小时div向左或向右移动。但是,div到达浏览器的左边缘时应停止移动 例如: 这就是我现在拥有的: #someElement{ background-image: url(images/someImg.png); width:200px; height:45px; position:absolute; right:68%; top:3px; } 这会在调整浏览器大小时更改div的位置,但在到达左边边缘时不会停止。好吧,不用右:为

我希望调整浏览器大小时div向左或向右移动。但是,div到达浏览器的左边缘时应停止移动

例如:

这就是我现在拥有的:

#someElement{
    background-image: url(images/someImg.png);
    width:200px;
    height:45px;
    position:absolute;
    right:68%;
    top:3px;
}

这会在调整浏览器大小时更改div的位置,但在到达左边边缘时不会停止。

好吧,不用
右:
为什么不使用
左:

left: 25%;

如果使元素的父元素相对定位。它将使内部元素相对于其父元素绝对定位

#someElementWrapper{
  position: relative;
}

#someElement{
  background-image: url(images/someImg.png);
  width:200px;
  height:45px;
  position:absolute;
}

可以在主体标记中设置最小宽度:

body {
    position: relative;
    min-width:100%;
    width: auto !important;
    width:100%;
}

这将阻止元素向左退出。

我考虑过了;但是,我希望该元素位于浏览器窗口的左边缘。