gpt4 book ai didi

html - 当父级没有固定宽度时,子级的高度为 100%

转载 作者:太空宇宙 更新时间:2023-11-04 03:54:21 25 4
gpt4 key购买 nike

好的,我在将鼠标悬停在我的投资组合部分时遇到了一些问题,让 height:100; 工作,我尝试了一系列类似问题的解决方案,但似乎没有任何效果。我也让它与媒体查询一起工作,但它是一堆额外的代码,我知道还有另一种方法可以做到这一点,我只是想不通!

查看我的 html:

<!-- Begin Portfolio -->
<section id="section2">

<div class="container portfolio">

<!-- Page Title -->
<div class="row page-title-2">
<div class="col-lg-12">
<h3>Portfolio</h3>
<hr>
<p>We also create some other stuff.</p>
</div>
</div>

<!-- Portfolio Filter -->
<div class="container text-center">
<ul class="nav nav-pills">
<li class="filter" data-filter="all">all</li>
<li class="filter" data-filter="print">print</li>
<li class="filter" data-filter="web">web</li>
<li class="filter" data-filter="branding">branding</li>
<li class="filter" data-filter="branding">illustration</li>
</ul>
</div>

<!-- Portfolio Items -->
<div class="container port-holder">
<ul id="myPortfolio" class="no-padding">
<li class="item branding col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-1.html" data-target="#myModal">
<img src="img/projects/thumbs/branding1.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Beach Sand</h4>
<em>Branding</em>
</span>
</span>
</a>
</li>
<li class="item web col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-2.html" data-target="#myModal">
<img src="img/projects/thumbs/web1.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>B&W Scene</h4>
<em>Web Design</em>
</span>
</span>
</a>
</li>
<li class="item print col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-3.html" data-target="#myModal">
<img src="img/projects/thumbs/print1.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Metal</h4>
<em>Print</em>
</span>
</span>
</a>
</li>
<li class="item branding col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-4.html" data-target="#myModal">
<img src="img/projects/thumbs/branding2.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Bridge Cityscape</h4>
<em>Branding</em>
</span>
</span>
</a>
</li>
<li class="item print col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-5.html" data-target="#myModal">
<img src="img/projects/thumbs/print2.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Camera</h4>
<em>Print</em>
</span>
</span>
</a>
</li>
<li class="item branding col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-6.html" data-target="#myModal">
<img src="img/projects/thumbs/branding3.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>B&W City</h4>
<em>Branding</em>
</span>
</span>
</a>
</li>
<li class="item web col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-7.html" data-target="#myModal">
<img src="img/projects/thumbs/web2.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Objects</h4>
<em>Web Design</em>
</span>
</span>
</a>
</li>
<li class="item print col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-8.html" data-target="#myModal">
<img src="img/projects/thumbs/print3.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Paradise</h4>
<em>Print</em>
</span>
</span>
</a>
</li>
<li class="item web col-xs-4 no-padding">
<a data-toggle="modal" href="projects/project-9.html" data-target="#myModal">
<img src="img/projects/thumbs/web3.jpg" alt="..." />
<span class="portfolio-hover">
<span>
<h4>Eary</h4>
<em>Web</em>
</span>
</span>
</a>
</li>
</ul>
</div>

</div>

</section>
<!-- End Portfolio -->

我的悬停 CSS:

.portfolio ul li:hover span.portfolio-hover {
opacity: 1;
}

.portfolio img {
max-width: 100%;
width: 100%;
height: 100% !important;
}

span.portfolio-hover {
background: rgba(39,39,39,0.95);
color: #8e8e8e;
width: 100%;
height: 100%;
display: table;
left: 0;
position: absolute;
top: 0;
bottom: 0;
opacity: 0;
-webkit-transition: opacity 500ms;
-moz-transition: opacity 500ms;
-o-transition: opacity 500ms;
transition: opacity 500ms;
}

span.portfolio-hover span {
display: table-cell;
text-align: center;
vertical-align: middle;
}

非常感谢任何帮助!

您还可以看到the live version here ,只需转到投资组合部分并将鼠标悬停在图像上即可。

最佳答案

将 span.portfolio-hover 从 display: table 更改为 display:block

关于html - 当父级没有固定宽度时,子级的高度为 100%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23005337/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com