gpt4 book ai didi

带有背景图片 url 的 CSS 变量

转载 作者:技术小花猫 更新时间:2023-10-29 10:30:09 50 4
gpt4 key购买 nike

我是不是误解了 css 变量的功能?我正在尝试将背景图片 url 传递给这样的变量:当我传递一些简单的东西(如颜色等)时,它似乎工作正常......

:root {
--slide-1: url(/static/images/slideshow/slide1.jpg) ;
--slide-2: url(/static/images/slideshow/slide2.jpg) ;
--slide-3: url(/static/images/slideshow/slide3.jpg) ;
--slide-4: url(/static/images/slideshow/slide4.jpg) ;
--slide-5: url(/static/images/slideshow/slide5.jpg) ;
}

//and then

.jumbotron > .jumbotron-slideshow:nth-child(1) {
background-image: var(--slide-1);
}

.jumbotron > .jumbotron-slideshow:nth-child(2) {
animation-delay: 6s;
background-image: var(--slide-2);
}

.jumbotron > .jumbotron-slideshow:nth-child(3) {
animation-delay: 12s;
background-image: var(--slide-3);
}

.jumbotron > .jumbotron-slideshow:nth-child(4) {
animation-delay: 18s;
background-image: var(--slide-4);
}

.jumbotron > .jumbotron-slideshow:nth-child(5) {
animation-delay: 24s;
background-image: var(--slide-5);
}

最佳答案

这是一个 bug在 Chrome 中,代码在 Firefox 中运行良好。

您现在必须坚持在 var() 中使用绝对 URL。

关于带有背景图片 url 的 CSS 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41748998/

50 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com