【发布时间】:2018-11-24 05:47:08
【问题描述】:
我在这部分有点卡住了。当背景图像位于 html 中时,我只在 html 中添加了 ACF php。现在我的 css 中有 2 个带有伪元素的形状。我将如何添加 php 以便它在 wordpress 上工作?
HTML
<section class="main-content-section home">
<section class="hero-section" style="background-image: url(images/home-hero@2x.jpg);"></section></section>
CSS
.hero-section:before,.home .hero-section:after{position: absolute; left: 0; top: 0; content: ""; background-image: url(../svgs/Rectangle.svg); background-position: left top; background-size: contain; background-repeat: no-repeat; width: 64.25%; height: 100%; z-index: -1;}
.home .hero-section:after{background-image: url(../svgs/Rectangle-Copy.svg); background-position: right bottom; left: auto; top: auto; right: 0; bottom: -46%; width: 63.125%;}
【问题讨论】:
-
After 前面应该有两个冒号:.hero-section::after
-
使用第 n 个元素可以解决这个问题吗?
-
并不真正需要使用伪元素 - 您可以在部分和样式之后动态地回显出您想要的任何内容。像
<div class="theFakePseudo"><img class="whateverIcon" src="<?php echo get_field('your_acf_image_field')['sizes']['thumbnail'];?>" alt="It's an icon"></div>
标签: php html css wordpress advanced-custom-fields