html - Slideshow/Changing background image
问题描述
I'm trying to set my page background image to be a slideshow of multiple images but I can't figure out a way to change the url of the image at a given interval while also using a fade in/out transition.
html {
background: url("mare.jpg") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
解决方案
您可以使用 JS 脚本更新 DOM
例如,您可以使用以下脚本更新您的身体标签:
<script>
document.body.style.background = "url("mare.jpg") no-repeat center center
</script>
推荐阅读
- r - Data.table:使用引号或表达式作为 i
- python - python从png获取像素位置
- regex - 用于匹配括号中所有内容的递归正则表达式 (PCRE)
- c++ - 如何减轻图像/纹理中薄元素的“闪烁”?
- c# - 在 Windows 服务中使用静态方法调用 web 表单中的数据而不创建新对象
- docker - 如何使用在 docker 中运行的 odoo 配置 pycharm
- python - 如何在 Python/psycopg2 中同时执行多个独立语句?
- excel - 将单元格值与工作表名称进行比较未按预期工作
- angular - Angular 5 ng-bootstrap datepicker 禁用数组中的特定日期
- python - 如何使用 PIL 更改像素的颜色?