【问题标题】:background-image not working properly in css背景图像在 css 中无法正常工作
【发布时间】:2016-11-21 21:30:30
【问题描述】:

我已将图像上传到服务器。图片地址是http://localhost:8080/wordpress/wp-content/uploads/2016/07/radio.png

我已经使用了这个 CSS :

 input[type=radio]:not(old) + label:after{
 content: '';
 position: absolute;
 top: 0;
 left: 23px;
 width: 100%;
 height: 100%;
 z-index: -1;
 background   : url('radio.png') no-repeat 0 0;

}

但图像未显示在 WordPress 页面上。它在我的简单 HTML 页面中工作,但在 wordpress 上不起作用?有什么想法吗?

在单选按钮 Js fiddle 中使用:https://jsfiddle.net/sjx84jf8/

它在这里工作,但不在 wordpress 上

【问题讨论】:

  • 你能分享你的 url 在哪里构建 wordpress 项目吗?
  • @MukeshRam 它没有上传到服务器上。我正在我的本地主机上工作
  • @MukeshRam 请检查此链接s31.postimg.org/ui9ho34qj/zzzzzzzzz.png
  • 我认为这可能是z-index 问题。请尝试在 .input[type=radio]:not(old) + label:after class... 中添加 z-index:1 或更多内容...可能是它的工作..
  • @MukeshRam 我已经更新了完整的 CSS,请检查

标签: css wordpress html radio-button


【解决方案1】:

如果无法实际看到发生了什么,也许不要使用绝对 URL(当它上线时这将成为一个问题)。如果您使用的是 FTP 客户端,例如 FileZilla,可以将文件路径直接从服务器复制到剪贴板以在 CSS 中使用(但同样不使用绝对 URL)。您的 WordPress 网站的其余部分是否正常工作?

【讨论】:

  • 我已将此地址用于图像 bt 相同问题s32.postimg.org/nz4jpdwat/radio.png
  • 您是否尝试过使用:/wordpress/wp-content/uploads/2016/07/radio.pngwordpress/wp-content/uploads/2016/ 07/radio.png?也可以尝试在你的 CSS 速记中使用 center 而不是 0 例如background: transparent url(...) no-repeat center center / cover
  • 是的,我已经尝试了所有可能的 URL 解决方案,但仍然没有运气。有没有其他方法可以在 wordpress 中显示单选按钮?
  • 你可以尝试类似 Shortcodes Ultimate 或者尝试关注something someone else has done
猜你喜欢
  • 2017-11-23
  • 1970-01-01
  • 2021-04-09
  • 1970-01-01
  • 2013-08-22
  • 1970-01-01
  • 1970-01-01
  • 2015-07-30
  • 2020-11-04
相关资源
最近更新 更多