【问题标题】:CSS transform scale to background imageCSS将比例转换为背景图像
【发布时间】:2017-07-25 18:56:01
【问题描述】:

我心爱的 CSS 部分影响图像

.split-banner .right-cl:hover img {
    -webkit-transform: scale(1.1);
    transform: scale(1.1);
}

我需要将上面的 CSS 应用到包含在 div 元素中的背景图像 我该怎么做?

【问题讨论】:

    标签: css background-image transform scale


    【解决方案1】:

    悬停时更改background-size。要模仿scale(1.1),请使用110%

    div {
      width: 560px;
      height: 400px;
      background: url('http://kenwheeler.github.io/slick/img/fonz1.png') center center no-repeat;
    }
    div:hover {
      background-size: 110%;
    }
    <div></div>

    【讨论】:

    • 感谢您的回答,但如果我想仅在背景上应用过渡,例如-webkit-transition: transform 5.05s ease-in-out;,有什么想法吗?
    • @OlivierPons 你能将你的背景和过渡样式应用到你正在使用的元素的伪元素(::before::after)吗?
    猜你喜欢
    • 1970-01-01
    • 2011-06-20
    • 1970-01-01
    • 2019-04-26
    • 1970-01-01
    • 1970-01-01
    • 2018-09-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多