【问题标题】:How to add gif to background如何将gif添加到背景
【发布时间】:2016-01-09 17:44:33
【问题描述】:

我使用了以下 CSS,我想知道是否可以将背景更改为使用一些 gif,即代替 background:white 使用以下 gif 作为背景 http://media.giphy.com/media/8OUdE03f3Nauc/giphy_s.gif

#carousel figure {

    display: block;
    position: absolute;
    width: 150px;
    height: 111px;
    left: 10px;
    top: 10px;
    background: white;
    overflow: hidden;
    border: solid 1px black;

}

我试过了 背景:url('http://media.giphy.com/media/8OUdE03f3Nauc/giphy_s.gif');

还有这个

背景图片:'http://media.giphy.com/media/8OUdE03f3Nauc/giphy_s.gif' 这不起作用...

【问题讨论】:

标签: html css


【解决方案1】:

试试这样:它的工作Demo

#carousel  {       
    background: white url("http://media.giphy.com/media/8OUdE03f3Nauc/giphy_s.gif") no-repeat center; 
// Added your gif background along with your code */
}

【讨论】:

  • 我试了一下,它对我不起作用,可能是什么问题?
  • 贴出你的相关html/css代码来帮助你更好
  • 我添加了 no-repeat-center 现在它可以工作了 :) 谢谢 1+
  • 如果我的代码帮助您接受它作为答案,那将帮助其他正在寻找相同解决方案的人:)
【解决方案2】:

您应该能够做到以下几点:

#carousel figure {

display: block;
position: absolute;
width: 150px;
height: 111px;
left: 10px;
top: 10px;
background: url('http://media.giphy.com/media/8OUdE03f3Nauc/giphy_s.gif');
overflow: hidden;
border: solid 1px black;

}

【讨论】:

  • 我试了一下,它对我不起作用,可能是什么问题?
  • 您可能需要下载 gif 并将其放在本地文件夹中
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-12-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-06
  • 1970-01-01
  • 2015-11-01
  • 2016-02-15
相关资源
最近更新 更多