如何在wordpress中添加图像URL路径



我已经创建了一个前端页面。请让我知道如何为WordPress添加URL,以及如何为背景图像添加CSS?

我的图像html元素

  1. <img src="./img/Hbook.jpg" class="img-responsive">

  2. 背景图像选择器

.firstSection{
background-image: url("../img/car.png"); 
margin-top:0px; 
background-size:cover;
background-position:50%;
background-repeat:no-repeat;
height:800px; 
display: table; 
width: 100%;

-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
top: 0;
left: 0;

}

您可以在php文件中使用背景图像属性inline css来设置wordpress图像url。你可以这样做代码。

<?php $image = 'pathto/image'; ?>
<section class="firstSection" style="background-image: url(<?php echo $image; ?>);">
<img src="./img/Hbook.jpg" class="img-responsive">
</section>

最新更新