概念很简单,我有一个 html5 页面,它是响应式的,只是 bground 图像不会随屏幕大小而变化:现在代码是:
<div id="home-gallery" class="gallery-container fullscreen">
<section id="home-welcome" class="slide-1 gallery-slide background-cover" style="background-image:url(static/img/home/image1.jpg)">
.....
<section id="home-campaigns" class="slide-2 gallery-slide background-cover" style="background-image:url(static/img/home/image2.jpg)">
也就是说,它使用一个常见的图像。我在 CSS 中尝试做的是:
@media (min-width:800px) { background-image: url(bg-800.jpg) }
@media (min-width:1024px) { background-image: url(bg-1024.jpg) }
@media (min-width:1280px) { background-image: url(bg-1280.jpg) }
但我不确定如何将style="background-image:
属性与 css 代码相关联?我应该写:
<section id="home-campaigns" class="slide-2 gallery-slide background-cover" style="background-image">
在CSS中#home-welcome background-image
@media (min-width:800px) { background-image: url(bg-1024.jpg) }
@media (min-width:1024px) { background-image: url(bg-1024.jpg) }
@media (min-width:1280px) { background-image: url(bg-1280.jpg) }
请帮忙。我试过了。`