【问题标题】:How to move background gradient left position如何将背景渐变向左移动位置
【发布时间】:2021-08-21 08:03:56
【问题描述】:

我正在尝试移动渐变的左侧位置。但它不起作用。

即使添加了background-position 属性,它也不起作用。

header{
height:100px;
border:1px solid blue;
background: linear-gradient(to top, #e20e0e 50px, #0000 50px);
background-position-x: 50px;
}
<header></header>

【问题讨论】:

  • 不明白你的问题:(你能提供一些关于你所期待的视觉效果吗?

标签: css


【解决方案1】:

关闭后台重复。

header{
height:100px;
border:1px solid blue;
background: linear-gradient(to top, #e20e0e 50px, #0000 50px);
background-position-x: 50px;
background-repeat: no-repeat;
}
<header></header>

【讨论】:

    【解决方案2】:

    您应该添加background-repeat: no-repeat; 属性。

    查看已经回答的类似问题。

    CSS Background Gradient with offset

    header{
    height:100px;
    border:1px solid blue;
    background: linear-gradient(to top, #e20e0e 50px, #0000 50px);
    background-position: 50px;
    background-repeat: no-repeat;
    }
    <header></header>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-14
      • 1970-01-01
      • 1970-01-01
      • 2020-07-02
      相关资源
      最近更新 更多