注意:以下答案适用于我之前编辑的有关过渡的上一个问题。
我有一个有两列的博客行。每列都有一个内部,其中包含顶部的图像和与博客相关的内容。我为图像拍摄了一个叠加伪元素,因此当您将鼠标悬停在内部时,叠加层应该应用于具有过渡的图像。一切正常,除非您将鼠标悬停在图像底部7px
空间的图像上,以覆盖我需要应用为margin-bottom: -7px
的图像。这是我页面上所有图像的问题。
.row {
position: relative;
width: 100%;
margin-bottom: 40px;
}
.blog-item-inner {
background-color: #fbfbfb;
box-sizing: border-box;
transition: all 0.4s ease-in-out;
}
.blog-img-inner {
position: relative;
overflow: hidden;
text-align: center;
transition: all 0.4s ease-in-out;
}
img {
height: auto;
max-width: 100%;
margin-bottom: -7px;
}
.blog-post-date {
position: absolute;
top: 35px;
left: 35px;
border: 2px solid #ffffff;
text-align: center;
width: 40px;
height: 35px;
z-index: 999;
}
.blog-post-date p {
font-family: 'Open Sans', sans-serif;
font-size: 15px;
font-weight: 700;
color: #ffffff;
line-height: 1;
margin-top: 0px;
padding: 5px 10px;
}
.blog-post-date span {
font-family: 'Open Sans', sans-serif;
font-size: 8px;
color: #ffffff;
line-height: 1;
font-weight: 400;
margin-bottom: 0;
display: block;
margin-top: 3px;
}
.blog-title-excerpt {
padding: 40px 40px 30px;
}
.blog-title-excerpt h3 {
font-family: 'Open Sans', sans-serif;
font-size: 15px;
font-weight: 700;
color: #000000;
margin-top: 0;
margin-bottom: 15px;
}
.blog-title-excerpt p {
font-family: 'Open Sans', sans-serif;
font-size: 13px;
font-weight: 400;
color: #888888;
margin-bottom: 0;
}
.blog-image {
position: relative;
margin-bottom: 24px;
transition: box-shadow 0.3s linear;
}
.blog-img-inner:before {
content: " ";
z-index: 10;
opacity: 0;
position: absolute;
height: 100%;
top: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
transition: all 0.3s ease-in-out;
}
.blog-item-inner:hover .blog-img-inner:before {
opacity: 1;
}
.blog-image .post-meta {
position: absolute;
right: 12px;
bottom: 12px;
display: block;
z-index: 15;
}
.blog-content a {
color: #222222;
text-decoration: none;
font-family: "Droid Serif", sans-serif;
}
.post-meta {
display: block;
margin-top: 10px;
cursor: pointer;
}
.post-meta span {
margin-right: 10px;
font-size: 12px;
color: #c0c0c0;
transition: all 0.3s ease-in-out;
}
.post-meta span:hover {
color: #777777;
}
.col6 {
width: 47.96%;
}
.col {
display: inline-block;
float: left;
margin-right: 4%;
}
.col:last-child {
margin-right: 0;
}

<div class="row clearfix">
<div class="col col6 blog-items">
<div class="blog-item-inner clearfix">
<div class="blog-img-inner">
<img src="https://image.ibb.co/b8UnFw/blog1.jpg" alt="blog1">
<div class="blog-post-date">
<p>18 <span>DEC</span></p>
</div>
</div>
<div class="blog-title-excerpt">
<h5 class="fancy-heading-s1"><a href="#">ENDLESS ROAD STARTS</a></h5>
<p>No one rejects, dislikes, or avoids pleasure those who do not know a pulse</p>
<div class="post-meta">
<span><i class="fa fa-thumbs-o-up"></i> 183</span>
<span><i class="fa fa-comment-o"></i> 57</span>
</div>
</div>
</div>
</div>
<div class="col col6 blog-items">
<div class="blog-item-inner">
<div class="blog-img-inner">
<img src="https://image.ibb.co/b8UnFw/blog1.jpg" alt="blog6 Image">
<div class="blog-post-date">
<p>12 <span>JUN</span></p>
</div>
</div>
<div class="blog-title-excerpt">
<h5 class="fancy-heading-s1"><a href="#">ENDLESS ROAD STARTS</a></h5>
<p>No one rejects, dislikes, or avoids pleasure those who do not know a puIse</p>
<div class="post-meta">
<span><i class="fa fa-thumbs-o-up"></i> 120</span>
<span><i class="fa fa-comment-o"></i> 18</span>
</div>
</div>
</div>
</div>
</div>
&#13;
答案 0 :(得分:1)
使用简单的transition: 0.4s ease;
.row {
position: relative;
width: 100%;
margin-bottom: 40px;
}
.blog-item-inner {
background-color: #fbfbfb;
box-sizing: border-box;
transition: all 0.4s ease-in-out;
}
.blog-img-inner {
position: relative;
overflow: hidden;
text-align: center;
transition: all 0.4s ease-in-out;
}
.blog-post-date {
position: absolute;
top: 35px;
left: 35px;
border: 2px solid #ffffff;
text-align: center;
width: 40px;
height: 35px;
z-index: 999;
}
.blog-post-date p {
font-family: 'Open Sans', sans-serif;
font-size: 15px;
font-weight: 700;
color: #ffffff;
line-height: 1;
margin-top: 0px;
padding: 5px 10px;
}
.blog-post-date span {
font-family: 'Open Sans', sans-serif;
font-size: 8px;
color: #ffffff;
line-height: 1;
font-weight: 400;
margin-bottom: 0;
display: block;
margin-top: 3px;
}
.blog-title-excerpt {
padding: 40px 40px 30px;
}
.blog-title-excerpt h3 {
font-family: 'Open Sans', sans-serif;
font-size: 15px;
font-weight: 700;
color: #000000;
margin-top: 0;
margin-bottom: 15px;
}
.blog-title-excerpt p {
font-family: 'Open Sans', sans-serif;
font-size: 13px;
font-weight: 400;
color: #888888;
margin-bottom: 0;
}
.blog-image {
position: relative;
margin-bottom: 24px;
transition: box-shadow 0.3s linear;
}
.blog-img-inner:before {
content: " ";
z-index: 10;
opacity: 0;
position: absolute;
height: 100%;
top: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
transition: 0.4s ease;
-webkit-transition: 0.4s ease;
-moz-transition: 0.4s ease;
-o-transition: 0.4s ease;
}
.blog-item-inner:hover .blog-img-inner:before {
opacity: 1;
}
.blog-image .post-meta {
position: absolute;
right: 12px;
bottom: 12px;
display: block;
z-index: 15;
}
.blog-content a {
color: #222222;
text-decoration: none;
font-family: "Droid Serif", sans-serif;
}
.post-meta {
display: block;
margin-top: 10px;
cursor: pointer;
}
.post-meta span {
margin-right: 10px;
font-size: 12px;
color: #c0c0c0;
transition: all 0.3s ease-in-out;
}
.post-meta span:hover {
color: #777777;
}
.col6 {
width: 47.96%;
}
.col {
display: inline-block;
float: left;
margin-right: 4%;
}
.col:last-child {
margin-right: 0;
}
<div class="row clearfix">
<div class="col col6 blog-items">
<div class="blog-item-inner clearfix">
<div class="blog-img-inner">
<img src="https://image.ibb.co/b8UnFw/blog1.jpg" alt="blog1">
<div class="blog-post-date">
<p>18 <span>DEC</span></p>
</div>
</div>
<div class="blog-title-excerpt">
<h5 class="fancy-heading-s1"><a href="#">ENDLESS ROAD STARTS</a></h5>
<p>No one rejects, dislikes, or avoids pleasure those who do not know a pulse</p>
<div class="post-meta">
<span><i class="fa fa-thumbs-o-up"></i> 183</span>
<span><i class="fa fa-comment-o"></i> 57</span>
</div>
</div>
</div>
</div>
<div class="col col6 blog-items">
<div class="blog-item-inner">
<div class="blog-img-inner">
<img src="https://image.ibb.co/b8UnFw/blog1.jpg" alt="blog6 Image">
<div class="blog-post-date">
<p>12 <span>JUN</span></p>
</div>
</div>
<div class="blog-title-excerpt">
<h5 class="fancy-heading-s1"><a href="#">ENDLESS ROAD STARTS</a></h5>
<p>No one rejects, dislikes, or avoids pleasure those who do not know a puIse</p>
<div class="post-meta">
<span><i class="fa fa-thumbs-o-up"></i> 120</span>
<span><i class="fa fa-comment-o"></i> 18</span>
</div>
</div>
</div>
</div>
</div>
答案 1 :(得分:1)
问题是你在代码中忘了“s”后的“s”。
过渡:所有0.3s缓入;
.row {
position: relative;
width: 100%;
margin-bottom: 40px;
}
.blog-item-inner {
background-color: #fbfbfb;
box-sizing: border-box;
transition: all 0.4s ease-in-out;
}
.blog-img-inner {
position: relative;
overflow: hidden;
text-align: center;
transition: all 0.4s ease-in-out;
}
.blog-post-date {
position: absolute;
top: 35px;
left: 35px;
border: 2px solid #ffffff;
text-align: center;
width: 40px;
height: 35px;
z-index: 999;
}
.blog-post-date p {
font-family: 'Open Sans', sans-serif;
font-size: 15px;
font-weight: 700;
color: #ffffff;
line-height: 1;
margin-top: 0px;
padding: 5px 10px;
}
.blog-post-date span {
font-family: 'Open Sans', sans-serif;
font-size: 8px;
color: #ffffff;
line-height: 1;
font-weight: 400;
margin-bottom: 0;
display: block;
margin-top: 3px;
}
.blog-title-excerpt {
padding: 40px 40px 30px;
}
.blog-title-excerpt h3 {
font-family: 'Open Sans', sans-serif;
font-size: 15px;
font-weight: 700;
color: #000000;
margin-top: 0;
margin-bottom: 15px;
}
.blog-title-excerpt p {
font-family: 'Open Sans', sans-serif;
font-size: 13px;
font-weight: 400;
color: #888888;
margin-bottom: 0;
}
.blog-image {
position: relative;
margin-bottom: 24px;
transition: box-shadow 0.3s linear;
}
.blog-img-inner:before {
content: " ";
z-index: 10;
opacity: 0;
position: absolute;
height: 100%;
top: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.5);
transition: all 0.3s ease-in-out;
}
.blog-item-inner:hover .blog-img-inner:before {
opacity: 1;
}
.blog-image .post-meta {
position: absolute;
right: 12px;
bottom: 12px;
display: block;
z-index: 15;
}
.blog-content a {
color: #222222;
text-decoration: none;
font-family: "Droid Serif", sans-serif;
}
.post-meta {
display: block;
margin-top: 10px;
cursor: pointer;
}
.post-meta span {
margin-right: 10px;
font-size: 12px;
color: #c0c0c0;
transition: all 0.3s ease-in-out;
}
.post-meta span:hover {
color: #777777;
}
.col6 {
width: 47.96%;
}
.col {
display: inline-block;
float: left;
margin-right: 4%;
}
.col:last-child {
margin-right: 0;
}
<div class="row clearfix">
<div class="col col6 blog-items">
<div class="blog-item-inner clearfix">
<div class="blog-img-inner">
<img src="https://image.ibb.co/b8UnFw/blog1.jpg" alt="blog1">
<div class="blog-post-date">
<p>18 <span>DEC</span></p>
</div>
</div>
<div class="blog-title-excerpt">
<h5 class="fancy-heading-s1"><a href="#">ENDLESS ROAD STARTS</a></h5>
<p>No one rejects, dislikes, or avoids pleasure those who do not know a pulse</p>
<div class="post-meta">
<span><i class="fa fa-thumbs-o-up"></i> 183</span>
<span><i class="fa fa-comment-o"></i> 57</span>
</div>
</div>
</div>
</div>
<div class="col col6 blog-items">
<div class="blog-item-inner">
<div class="blog-img-inner">
<img src="https://image.ibb.co/b8UnFw/blog1.jpg" alt="blog6 Image">
<div class="blog-post-date">
<p>12 <span>JUN</span></p>
</div>
</div>
<div class="blog-title-excerpt">
<h5 class="fancy-heading-s1"><a href="#">ENDLESS ROAD STARTS</a></h5>
<p>No one rejects, dislikes, or avoids pleasure those who do not know a puIse</p>
<div class="post-meta">
<span><i class="fa fa-thumbs-o-up"></i> 120</span>
<span><i class="fa fa-comment-o"></i> 18</span>
</div>
</div>
</div>
</div>
</div>