我将假设一些事情来回答这个问题。你可能已经在做了,所以如果这不是正确的答案,请告诉我。
WordPress已经为html、body和head定义了标记。不能在一个页面上定义两次。在WordPress内容中工作时,标记始终保存到页面正文中。最好的做法是在head元素中包含所有样式表和样式标记,但这不是必需的。在您的情况下,您希望样式显示在标记旁边。
除此之外,我还做了一些小改动:
添加type="text/css"
到您的样式标记更改图像src
相对而非绝对试试看。您仍然需要检查页面源代码,以确保没有任何标记被剥离或更改。我不熟悉wp bakery的html块,但它们可能不允许一些标记。
<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>