Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.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
Html 如何在背景中定位封面图像?_Html_Css - Fatal编程技术网

Html 如何在背景中定位封面图像?

Html 如何在背景中定位封面图像?,html,css,Html,Css,我在div的背景中放置了一个图像,代码如下: background: url(../images/cover-image.jpg) no-repeat 50% 100% fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; height: 30rem; 但我现在的问题是,我想移动div中图像的可见部分。图片的底部

我在div的背景中放置了一个图像,代码如下:

background: url(../images/cover-image.jpg) no-repeat 50% 100% fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
height: 30rem;
但我现在的问题是,我想移动div中图像的可见部分。图片的底部应该在div的底部,但我可以更改
背景中的所有内容:
中底
50%100%
等)语句,什么都不会发生

有人能给我一个提示吗?

试试使用

background-position: center bottom;

背景尺寸:封面意味着背景图像将始终采用div的全宽和全高

如果拆下这些零件,则应能正常工作:

-webkit-background-size: cover;
-moz-background-size: cover;
 -o-background-size: cover;
 background-size: cover;

您需要删除“背景”中的其他样式,只需放置:

background-position:bottom;

请看这里的小提琴:

作为一行,这将是:


background:透明url(../images/cover image.jpg)中底/封面无重复固定

在没有任何HTML的情况下很难定位背景图像。您是否尝试过使用背景大小:contain?是否有向下投票的原因?如果用户愿意为原因留下评论,那就太好了;-)我认为固定和底部的组合是问题所在,但为什么呢?