css按比例向左延伸,CSS宽度100vw只延伸到一侧(CSS width 100vw only extending to one side)...

CSS宽度100vw只延伸到一侧(CSS width 100vw only extending to one side)

我正在使用以下代码:

#div {

position: absolute;

left: 0;

right: 0;

width: 100vw !important;

height: 210px !important;

background-image: url('imageurl.com');

background-position: center;

}

我所拥有的是一个div,我试图通过祖父母(屏幕宽度)来适应(宽度方向)。 正如您在上面的代码中看到的那样,我尝试使用width: 100vw ,但它只向右延伸,左侧保持原样。

有谁知道为什么?

I'm using the following code:

#div {

position: absolute;

left: 0;

right: 0;

width: 100vw !important;

height: 210px !important;

background-image: url('imageurl.com');

background-position: center;

}

What I have is an div that I'm trying to get to fit (width-wise) with a grandparent (screen-width). As you can see in the above code, I have at

你可能感兴趣的:(css按比例向左延伸)