我正在尝试向每个 wordpress 页面添加不同的 bg 图像。http://www.designstest.co.uk/print-quote
这是我正在使用的代码:
<?php
$class = '';
if (is_page('print-quote')) {
$class = 'main_image_quote';
} elseif (is_page('case-studies')) {
$class = 'main_image_case';
} elseif (is_page('contact')) {
$class = 'main_image_contact';
} elseif (is_page('services')) {
$class = 'main_image_services';
} elseif (is_page('news')) {
$class = 'main_image_news';
} elseif (is_page('suppliers')) {
$class = 'main_image_suppliers';
} ?>
<div id="main_image" <?php if($class) echo ' class=' . $class . '"'; ?>>
和CSS:
#main_image {
background: url(images/SRPM-Home-Page-Background.png) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#main_image.main_image_quote {
background-image: url(images/SRPM-Print-Quote-Page-Background.png);
}
#main_image.main_image_case {
background-image: url(images/SRPM-Case-Studies-Clients-Page-Background.png);
}
#main_image.main_image_contact {
background-image: url(images/SRPM-Contact-Page-Background.png);
}
#main_image.main_image_services {
background-image: url(images/SRPM-Services-Page-Background.png);
}
#main_image.main_image_news {
background-image: url(images/SRPM-News-Page-Background.png);
}
#main_image.main_image_suppliers {
background-image: url(images/SRPM-Suppliers-Page-Background.png);
}
我哪里错了?它没有做它应该做的事情:(