我是否需要img2中的任何这些代码,并且它们没用,或者我保留其中任何代码?
background-position:center;
当删除它时,它仍然居中,所以我不确定该代码有多么有用。
background-repeat: no-repeat;
当我增加背景空间时,放入,背景-repeat;重复;什么都没发生。 所以,我不确定代码是多么有用。
background-size: 180px 180px;
当我从代码中删除它时,没有任何反应,所以我不确定该代码是否有用。
.img2 {
background-repeat: no-repeat;
background-position:center;
background-size: 180px 180px;
}
删除它们:
https://jsfiddle.net/yyqcgvpL/1/
你说什么?
另外,这两个样式代码在img2上无法运行或禁用的具体原因是什么?
background-repeat: no-repeat;
甚至重复
background-position:center;
答案 0 :(得分:0)
尝试
background:cover;
它将填写整个页面
答案 1 :(得分:0)
background-position:center;
在水平位置等于50%,在垂直位置等于50%。
background-repeat:no-repeat;
背景图像仅显示一次,并远离文本。
background-size:180px 180px;
将尺寸固定在不同的设备上非常有用。
可用于修复和平滑对象。 您可以访问此处了解详情:https://www.w3schools.com/css/css_background.asp