图像上的图像叠加在WordPress中不起作用,但在“普通html编辑器”中起作用。

时间:2019-03-13 作者:yazn

我有一系列的照片,有一个覆盖图,在html编辑器中似乎可以很好地工作,但当我将其切换到wordpress(wp bakery html block)时,覆盖图似乎不起作用

有什么想法吗?

这是代码

http://scratchpad.io/intelligent-start-2820

当做

1 个回复
SO网友:MikeNGarrett

我将假设一些事情来回答这个问题。你可能已经在做了,所以如果这不是正确的答案,请告诉我。

WordPress已经为html、body和head定义了标记。不能在一个页面上定义两次。在WordPress内容中工作时,标记始终保存到页面正文中。最好的做法是在head元素中包含所有样式表和样式标记,但这不是必需的。在您的情况下,您希望样式显示在标记旁边。

除此之外,我还做了一些小改动:

添加type="text/css" 到您的样式标记src 相对而非绝对

<style type="text/css">
  .column_portfolio {
    float: left;
    width: 33.33%;
    padding: 5px;
    box-sizing: border-box;
  }

  /* Clearfix (clear floats) */
  .row_portfolio::after {
    content: "";
    clear: both;
    display: table;
  }

  .container_portfolio {
    position: relative;
    width: 100%;
  }

  .image {
    opacity: 1;
    display: block;
    width: 100%;
    height: auto;
    backface-visibility: hidden;

  }


  .button_toShow {
    transition: .5s ease;
    opacity: 0;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    text-align: center;
  }

  .text_toShow {
    transition: .5s ease;
    opacity: 1;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    -ms-transform: translate(-50%, -50%);
    text-align: center;
  }


  .container_portfolio:hover .text_toShow {
    display: none;
  }

  .container_portfolio:hover .image {
    opacity: 0.3;
  }

  .container_portfolio:hover .button_toShow {
    opacity: 1;
  }

  .container_portfolio:hover .text_toShow {
    opacity: 1;
  }


  .container_portfolio #overlay_portfolio {
    position: relative !important;
    cursor: pointer !important;
    display: block;

  }

  .container_portfolio #overlay_portfolio:hover:before {
    background: none !important;
  }


  .container_portfolio #overlay_portfolio:before {
    content: "" !important;
    position: absolute !important;
    display: block;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background-color: lightblue;
  }
</style>
<div class="row_portfolio">
  <div class="column_portfolio">
    <div class="container_portfolio">
      <div id="overlay_portfolio">
        <img src="/wordpress-8/wp-content/uploads/2019/02/IMG_4774_2.jpg" alt="" class="image" style="width:100%">
      </div>

      <div class="text_toShow">
        <i id="camera_icon" class="fas fa-camera"></i>
        <h2 id="titles_portfolio">WEDDING PHOTOGRAPHY</h2>
      </div>
      <div class="button_toShow">
        <button class="button_hover_portfolio">VIEW GALLERY</button>
      </div>
    </div>
  </div>


  <div class="column_portfolio">

    <div class="container_portfolio">
      <div class="overlay_portfolio">
        <img src="/wp-content/uploads/2019/03/IMG_4535.jpg" alt="" class="image" style="width:100%">
      </div>

      <div class="text_toShow">
        <i id="camera_icon" class="fas fa-camera"></i>
        <h2 id="titles_portfolio">FULL WEDDING</h2>
      </div>
      <div class="button_toShow">
        <button class="button_hover_portfolio">VIEW GALLERY</button>
      </div>
    </div>
  </div>

  <div class="column_portfolio">

    <div class="container_portfolio">
      <div class="overlay_portfolio">
        <img src="/wp-content/uploads/2019/03/IMG_7033-Version-2-1.jpg" alt="" class="image" style="width:100%">
      </div>

      <div class="text_toShow">
        <i id="camera_icon" class="fas fa-camera"></i>

        <h2 id="titles_portfolio">PORTRAITS</h2>
      </div>
      <div class="button_toShow">
        <button class="button_hover_portfolio">VIEW GALLERY</button>
      </div>
    </div>
  </div>
</div>

相关推荐

是否有任何WordPress函数可以从帖子内容中检索特定的html元素

我正在开发wordpress博客主题,我想使用文章内容中的heading1元素(标记)作为我的文章标题,而不是默认标题。实际上,我希望我的帖子标题比默认标题长一点(为了满足SEO建议,我需要设置更短的标题)。也许我需要这样的东西<?php get_the_tag(); ?>而不是<?php the_title(); ?>