我有 4 个具有相同数量 li 项目的无序列表。它们在显示器中并排排列。有没有一种简单的方法可以告诉每个孩子 li 项目(ul-one li:nth-child(1)、ul-two li:nth-child(1) 等)具有相同的高度?原因是当我填写数据时,一个 UL 比其他 UL 高得多,它破坏了结构。
我可以想到几种方法来实现这一点:
jQuery (parent('ul') = nth-child index)
CSS w/ Classes per row
Convert to Table
这些都不是理想的:-( CSS 中是否有任何伪元素可以在没有所有 4 个列表项的特定类的情况下自动配置它?让我演示一个示例...
http://www.sinsysonline.com/repair/price.html
(选择提货以查看价格表)
这是我的 HTML 标记:
<div id="price_charts">
<div id="pri_drop-off" class="grid_12">
<ul class="pricing_table">
<li class="price_block">
<a href="dropoff.html"><h2> </h2></a>
<div class="price">
<div class="price_figure price_con">
<span class="price_number"> </span>
<span class="price_tenure"> </span>
</div>
</div>
<ul class="features serv">
<li class="category"><a href="services_hwrep.html">Hardware Repair</a></li>
<li class="category"><a href="services_netts.html">Network Troubleshooting</a></li>
<li class="category"><a href="services_printsetup.html">Printer Setup</a></li>
<li class="category"><a href="services_osinstall.html">Operating System Install</a></li>
<li class="category"><a href="services_email.html">E-Mail Setup</a></li>
<li class="category"><a href="services_compsetup.html">Computer Setup</a></li>
<li class="category"><a href="services_swinstall.html">Software Install</a></li>
<li class="category"><a href="services_tune.html">Computer Tune Up</a></li>
<li class="category"><a href="services_hwup.html">Hardware Upgrade</a></li>
<li class="category"><a href="services_backup.html">Data Backup & Recovery</a></li>
<li class="category"><a href="services_wifi.html">Wireless Troubleshooting</a></li>
</ul>
</li>
<li class="price_block">
<a href="pickup.html"><h3>Desktop</h3></a>
<div class="price">
<div class="price_figure">
<span class="price_number">$30</span>
<span class="price_tenure">per hour</span>
</div>
</div>
<ul class="features">
<li><a href="services_hwrep.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_netts.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_printsetup.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_osinstall.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_email.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_compsetup.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_swinstall.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_tune.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_hwup.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_backup.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_wifi.html"><img src="../css/images/check.png" /></a></li>
</ul>
<div class="footer">
<a href="contact.html" class="action_button">Contact Us</a>
</div>
</li>
<li class="price_block">
<a href="onsite.html"><h3>Laptop</h3></a>
<div class="price">
<div class="price_figure">
<span class="price_number">$50</span>
<span class="price_tenure">per hour</span>
</div>
</div>
<ul class="features">
<li><a href="services_hwrep.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_netts.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_printsetup.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_osinstall.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_email.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_compsetup.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_swinstall.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_tune.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_hwup.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_backup.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_wifi.html"><img src="../css/images/check.png" /></a></li>
</ul>
<div class="footer">
<a href="contact.html" class="action_button">Contact Us</a>
</div>
</li>
<li class="price_block">
<a href="remote.html"><h3>Server</h3></a>
<div class="price">
<div class="price_figure">
<span class="price_number">$30</span>
<span class="price_tenure">per hour</span>
</div>
</div>
<ul class="features">
<li><a href="services_hwrep.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_netts.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_printsetup.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_osinstall.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_email.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_compsetup.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_swinstall.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_tune.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_hwup.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_backup.html"><img src="../css/images/check.png" /></a></li>
<li><a href="services_wifi.html"><img src="../css/images/check.png" /></a></li>
</ul>
<div class="footer">
<a href="contact.html" class="action_button">Contact Us</a>
</div>
</li>
</ul>
</div>
</div>
以及当前用于悬停效果的 JS:
$('ul.features li').on('mouseenter mouseleave', function () {
$('ul.features > li:nth-child(' + ($(this).index() + 1) + ' )').toggleClass('pri_active');
$('ul.features > li.category:nth-child(' + ($(this).index() + 1) + ' )').toggleClass('pri_cat');
});
还有一大堆 CSS 我会帮你节省时间去破译。
所以,基本问题:
有没有一种 CSS 方法可以告诉每个等效的子元素自动调整为 4 个中最大的子元素?(不用说 (:first-child, :nth-child(2) 等)