2016-09-23 24 views
3

我有3个框在页面上具有滚动效果,当有人将鼠标移到框上时,它会将内容从段落更改为无序列表,并显示“查看更多”按钮。按钮对齐将不会坐在我告诉它的位置

问题是每个盒子在列表中有不同数量的项目,并且按钮在列表的末尾对齐,我试图将其与盒子的底部对齐。

我尝试了一些建议,我发现通过这些论坛寻找,但仍然无法使其工作。有人可以直接指向我吗?我错过了什么?

页面位于下方,理想情况下,我想将所有按钮对齐到底部,与按钮出现在第一个框中的位置相同。

http://wpdev.quadris.co.uk/what-we-do/

对位IM一起工作的代码如下

\t .box { 
 

 
    cursor: pointer; 
 
    height: 340px; 
 
    position: relative; 
 
    overflow: hidden; 
 
    width: 100%; 
 
} 
 

 
.box .fa { 
 
    position: relative; 
 
    margin-top: 40%; 
 
    left: 43%; 
 
    font-size: 48px; 
 
} 
 

 
.box h2 { 
 
     text-align: center; 
 
    position: absolute; 
 
    font-size: 24px; 
 
    left: 5%; 
 
    -webkit-transition: all 300ms ease-out; 
 
    -moz-transition: all 300ms ease-out; 
 
    -o-transition: all 300ms ease-out; 
 
    -ms-transition: all 300ms ease-out; 
 
    transition: all 300ms ease-out; 
 
} 
 
.box p{ 
 
     text-align: center; 
 
    position: relative; 
 
    top: 30%; 
 
    padding: 3%; 
 
    padding-top: 0; 
 
} 
 
.box .overbox p { 
 
    text-align: center; 
 
    color: #fff; 
 
    font-size: 16px; 
 
} 
 
.box .overbox { 
 
    background-color: #424545; 
 
    position: absolute; 
 
    top: 0; 
 
    left: 0; 
 
    color: #fff; 
 
    z-index: 100; 
 
    -webkit-transition: all 300ms ease-out; 
 
    -moz-transition: all 300ms ease-out; 
 
    -o-transition: all 300ms ease-out; 
 
    -ms-transition: all 300ms ease-out; 
 
    transition: all 300ms ease-out; 
 
    opacity: 0; 
 
    width: 100%; 
 
    height: 340px; 
 
    padding: 30px 20px; 
 

 
} 
 

 
.box:hover .overbox { opacity: 1; } 
 

 
.box .overtext { 
 
    -webkit-transition: all 300ms ease-out; 
 
    -moz-transition: all 300ms ease-out; 
 
    -o-transition: all 300ms ease-out; 
 
    -ms-transition: all 300ms ease-out; 
 
    transition: all 300ms ease-out; 
 
    transform: translateY(40px); 
 
    -webkit-transform: translateY(40px); 
 
} 
 

 
.box .title { 
 
    font-size: 16px; 
 
    text-transform: none; 
 
    opacity: 0; 
 
    transition-delay: 0.1s; 
 
    transition-duration: 0.2s; 
 
} 
 

 
.box:hover .title, 
 
.box:focus .title { 
 
    opacity: 1; 
 
    transform: translateY(0px); 
 
    -webkit-transform: translateY(0px); 
 
} 
 

 
.box .tagline { 
 
    font-size: 0.8em; 
 
    color:#fff; 
 
    opacity: 0; 
 
    transition-delay: 0.2s; 
 
    transition-duration: 0.2s; 
 
} 
 

 
.box:hover .tagline, 
 
.box:focus .tagline { 
 
    opacity: 1; 
 
    transform: translateX(0px); 
 
    -webkit-transform: translateX(0px); 
 
    color: #fff; 
 
} 
 

 
.box .overbox .btn-primary { 
 
    position: relative; 
 
\t bottom: 0; 
 
    background-color: #9e3039; 
 
    color: #fff; 
 
    border-style: none; 
 

 
} 
 
.box .overbox .btn-primary a, a:hover { 
 
    color: #fff; 
 
}
<div class="box"> <h2>Managed IT Solutions</h2> 
 
    
 
<p>No matter what your IT requirement is, we can help. 
 
Whether you are looking for a fully managed IT service or one tailored to supplement your internal team, we have a solution for you. 
 
</p> 
 
<i class="fa fa-gg"></i> 
 
    <div class="overbox"> 
 
    <div class="title overtext"> 
 
\t \t <ul> 
 
\t \t \t <li>Tailored IT Support</li> 
 
\t \t \t <li>Service Desk</li> 
 
\t \t \t <li>Networking Monitoring</li> 
 
\t \t \t <li>Managed Disaster Recovery</li> 
 
\t \t \t <li>IT PRocurement</li> 
 
\t \t \t <li>Managed Security</li> 
 
\t \t \t <li>Co-Location Services</li> 
 
\t \t \t <li>Hosted Services</li> 
 
\t \t \t <li>Domain Management</li> 
 
\t \t \t <li>Security Vulnerability Scanning</li> 
 
\t \t </ul> 
 
\t \t  <div class="tagline overtext"><button type="button" class="btn btn-primary btn-lg btn-block"><a href="#">Find Out More</a></button> </div> 
 

 
\t </div> 
 
    </div> 
 
</div>

任何帮助将非常感激。

感谢,

PhilB

+0

位置的按钮abolute,或使用Flexbox的。 – CBroe

回答

2

设置height:90%.text类因而这在.overbox底部放置您的按钮。

.box .title { 
    font-size: 16px; 
    text-transform: none; 
    opacity: 0; 
    transition-delay: 0.1s; 
    transition-duration: 0.2s; 
    height: 90%; /*Add this*/ 
} 
+0

@philb确实接受或赞成答案,如果它为你工作。 – frnt

+0

这是一个很好的解决方案,但OP还应该添加“overflow:scroll”来防止在内容上悬停按钮(当列表太长时) – JuniorDev

+0

@JuniorDev是的,如果需要,他可以添加overflow-y:scroll。 – frnt

0

查看下面的代码片段。

button留在你需要它取决于overbox留。所以,在HTML中.overbox的最底部,将包含button.overtextdiv并把它作为一个直接子overbox

然后设置position: absolute到包含buttontagline)的divbottom:0bottom:5px正如我在下面的代码段已设置(所以它不是完全在底部)

希望它帮助。

.box { 
 

 
    cursor: pointer; 
 
    height: 340px; 
 
    position: relative; 
 
    overflow: hidden; 
 
    width: 100%; 
 
} 
 

 
.box .fa { 
 
    position: relative; 
 
    margin-top: 40%; 
 
    left: 43%; 
 
    font-size: 48px; 
 
} 
 

 
.box h2 { 
 
     text-align: center; 
 
    position: absolute; 
 
    font-size: 24px; 
 
    left: 5%; 
 
    -webkit-transition: all 300ms ease-out; 
 
    -moz-transition: all 300ms ease-out; 
 
    -o-transition: all 300ms ease-out; 
 
    -ms-transition: all 300ms ease-out; 
 
    transition: all 300ms ease-out; 
 
} 
 
.box p{ 
 
     text-align: center; 
 
    position: relative; 
 
    top: 30%; 
 
    padding: 3%; 
 
    padding-top: 0; 
 
} 
 
.box .overbox p { 
 
    text-align: center; 
 
    color: #fff; 
 
    font-size: 16px; 
 
} 
 
.box .overbox { 
 
    background-color: #424545; 
 
    position: absolute; 
 
    top: 0; 
 
    left: 0; 
 
    color: #fff; 
 
    z-index: 100; 
 
    -webkit-transition: all 300ms ease-out; 
 
    -moz-transition: all 300ms ease-out; 
 
    -o-transition: all 300ms ease-out; 
 
    -ms-transition: all 300ms ease-out; 
 
    transition: all 300ms ease-out; 
 
    opacity: 0; 
 
    width: 100%; 
 
    height: 340px; 
 
    padding: 30px 20px 80px; 
 
    box-sizing:border-box; 
 

 
} 
 

 
.box:hover .overbox { opacity: 1; } 
 

 
.box .overtext { 
 
    -webkit-transition: all 300ms ease-out; 
 
    -moz-transition: all 300ms ease-out; 
 
    -o-transition: all 300ms ease-out; 
 
    -ms-transition: all 300ms ease-out; 
 
    transition: all 300ms ease-out; 
 
    transform: translateY(40px); 
 
    -webkit-transform: translateY(40px); 
 

 
} 
 

 
.box .title { 
 
    font-size: 16px; 
 
    text-transform: none; 
 
    opacity: 0; 
 
    transition-delay: 0.1s; 
 
    transition-duration: 0.2s; 
 
} 
 

 
.box:hover .title, 
 
.box:focus .title { 
 
    opacity: 1; 
 
    transform: translateY(0px); 
 
    -webkit-transform: translateY(0px); 
 
} 
 

 
.box .tagline { 
 
    font-size: 0.8em; 
 
    color:#fff; 
 
    opacity: 0; 
 
    transition-delay: 0.2s; 
 
    transition-duration: 0.2s; 
 
} 
 

 
.box:hover .tagline, 
 
.box:focus .tagline { 
 
    opacity: 1; 
 
    transform: translateX(0px); 
 
    -webkit-transform: translateX(0px); 
 
    color: #fff; 
 
} 
 

 
.box .overbox .tagline { 
 
position:absolute; 
 
\t bottom: 5px; 
 
    background-color: #9e3039; 
 
    color: #fff; 
 
    border-style: none; 
 

 
} 
 
.box .overbox .tagline .btn-primary{ 
 
    background-color: #9e3039; 
 
    } 
 
.box .overbox .btn-primary a, a:hover { 
 
    color: #fff; 
 
} 
 
<div class="box"> <h2>Managed IT Solutions</h2> 
 
    
 
<p>No matter what your IT requirement is, we can help. 
 
Whether you are looking for a fully managed IT service or one tailored to supplement your internal team, we have a solution for you. 
 
</p> 
 
<i class="fa fa-gg"></i> 
 
    <div class="overbox"> 
 
    <div class="title overtext"> 
 
\t \t <ul> 
 
\t \t \t <li>Tailored IT Support</li> 
 
\t \t \t <li>Service Desk</li> 
 
\t \t \t <li>Networking Monitoring</li> 
 
\t \t \t <li>Managed Disaster Recovery</li> 
 
\t \t \t <li>IT PRocurement</li> 
 
\t \t \t <li>Managed Security</li> 
 
\t \t \t <li>Co-Location Services</li> 
 
\t \t \t <li>Hosted Services</li> 
 
\t \t \t <li>Domain Management</li> 
 
\t \t \t <li>Security Vulnerability Scanning</li> 
 
\t \t </ul> 
 
\t \t  
 

 
\t </div> 
 
    <div class="tagline overtext"><button type="button" class="btn btn-primary btn-lg btn-block"><a href="#">Find Out More</a></button> </div> 
 
    </div> 
 
</div> 
 

 

 
<div class="box"> <h2>Managed IT Solutions</h2> 
 
    
 
<p>No matter what your IT requirement is, we can help. 
 
Whether you are looking for a fully managed IT service or one tailored to supplement your internal team, we have a solution for you. 
 
</p> 
 
<i class="fa fa-gg"></i> 
 
    <div class="overbox"> 
 
    <div class="title overtext"> 
 
\t \t <ul> 
 
\t \t \t <li>Tailored IT Support</li> 
 
\t \t \t <li>Service Desk</li> 
 
\t \t \t <li>Networking Monitoring</li> 
 
\t \t \t <li>Managed Disaster Recovery</li> 
 
\t \t \t <li>IT PRocurement</li> 
 
\t \t \t <li>Managed Security</li> 
 
\t \t \t <li>Co-Location Services</li> 
 
\t \t \t <li>Hosted Services</li> 
 
\t \t \t <li>Domain Management</li> 
 
\t \t \t <li>Security Vulnerability Scanning</li> 
 
      <li>Security Vulnerability Scanning</li> 
 
      <li>Security Vulnerability Scanning</li> 
 
      <li>Security Vulnerability Scanning</li> 
 
     
 
\t \t </ul> 
 
\t \t  
 

 
\t </div> 
 
    <div class="tagline overtext"><button type="button" class="btn btn-primary btn-lg btn-block"><a href="#">Find Out More</a></button> </div> 
 
    </div> 
 
</div> 
 

 
<div class="box"> <h2>Managed IT Solutions</h2> 
 
    
 
<p>No matter what your IT requirement is, we can help. 
 
Whether you are looking for a fully managed IT service or one tailored to supplement your internal team, we have a solution for you. 
 
</p> 
 
<i class="fa fa-gg"></i> 
 
    <div class="overbox"> 
 
    <div class="title overtext"> 
 
\t \t <ul> 
 
\t \t \t <li>Tailored IT Support</li> 
 
\t \t \t <li>Service Desk</li> 
 
\t \t \t <li>Networking Monitoring</li> 
 
\t \t \t <li>Managed Disaster Recovery</li> 
 

 
\t \t </ul> 
 
\t \t  
 

 
\t </div> 
 
    <div class="tagline overtext"><button type="button" class="btn btn-primary btn-lg btn-block"><a href="#">Find Out More</a></button> </div> 
 
    </div> 
 
</div>

+0

嗨米哈伊·T, 我想你的方法,并且它没有效果的按钮,但它像是定位它,当我这样做,容器的中心。 尽管如此,谢谢你, – philb

+0

以及在我的片段中一切正常。你确定你复制并改变了我添加/更改为你的代码的所有内容吗? –

+0

嗨,是的,经过反思,我发现我已经添加到错误的CSS文件。我很抱歉。它并没有把它放在同一个地方,但它确实比我原来的版本更好。 这两个答案都提供了工作。 菲尔 – philb