php - 在内联 CSS 中使用时,URL 采用自动间距
问题描述
我遇到了一个问题。我在内联 CSS 中使用了 wp get_the_post_thumbnail_url(),但它不能正常工作。URL 通过删除的斜杠占用空格。
if ( has_post_thumbnail() ) {
$startnext_features_box_markup .='
<div class="single-repair-services" style="background-image: url("'.get_the_post_thumbnail_url().'");">';
解决方案
试试这个编辑过的代码
if ( has_post_thumbnail() ) {
$image = get_the_post_thumbnail_url();
$startnext_features_box_markup .='
<div class="single-repair-services" style="background-image: url(\''.$image.'\');">';
推荐阅读
- jquery - 有没有办法使用 JQuery 从 css 类中获取类定义或值?
- php - 使用 PHP 从数据库中检索图像并在 Flutter 项目中使用(在 Dart 中)
- c# - C#“访问路径被拒绝”netcore linux/raspbian 如何获得写入系统文件的访问权限
- java - 两个模式之间的Java正则表达式匹配
- python - 如何旋转 matplotlib 地图?
- hibernate - 无法建立实体管理器工厂-Hibernet AWS
- django - Django 正在验证没有为必填字段选择值的表单集
- django - 多对多关系 - 电影 - 角色 - 演员
- javascript - forEach 中用于 redux 减速器的突变(使用 immer.js)
- flutter - 如何更改 Scaffold 小部件的抽屉颜色