【问题标题】:Using "background-position" but my background image is disappearing [closed]使用“背景位置”,但我的背景图像正在消失 [关闭]
【发布时间】:2018-02-20 17:54:42
【问题描述】:

我想使用背景图片,但我想调整它的位置。我想将它向上移动-10像素。我注意到当我添加背景位置时,我的图像会消失。所以我尝试将所有内容都设置为零,所以什么都不会移动,就像这样

#pageTitle {
    display: flex;
    padding: 10px;
    height: 100px;
    background-image: url(http://hddfhm.com/images/clipart-110-scale-14.jpg)
    background-position: 0px 0px;
}

但即便如此,我的背景图片还是消失了——https://jsfiddle.net/eq6zxpcb/5/。如果我删除

background-position: 0px 0px;

背景图像出现了,但它不在我想要的位置。如何在不使图像消失的情况下添加背景位置?

【问题讨论】:

  • background-image 样式后没有分号,这似乎是语法错误。查看更新的fiddle
  • 玫瑰是红色的,紫罗兰是蓝色的,你少了一个';'在第 5 行

标签: html css background-image background-position


【解决方案1】:
#pageTitle {
    display: flex;
    padding: 10px;
    height: 100px;
    background-image: url(http://hddfhm.com/images/clipart-110-scale-14.jpg);
    background-position: 0px 0px;
}

在此之后background-image: url(http://hddfhm.com/images/clipart-110-scale-14.jpg) 分号 (;) 不存在

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-03-31
    • 1970-01-01
    • 2017-01-06
    • 2021-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多