我认为这是一个简单的修复,但我似乎无法弄清楚。
我有一个包含三个单元格的表格,点击后会显示隐藏的 div。但是,当显示 div 时,它会推动它周围的单元格。我正在寻找一种方式,其中 div 将显示但不限于单元格的大小,并且不会影响它周围的其他单元格。
如果有比在表格中更好的组织方式,请告诉我。
这是我的问题的一些示例代码:
CSS:
<style>
.iphone {
display: none;
}
</style>
Javascript/JQuery:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
//Choose iPhone model
function slideonlyone(thechosenone) {
$('.model').each(function(index) {
if ($(this).attr("id") == thechosenone) {
$(this).slideDown(200);
}
else {
$(this).slideUp(600);
}
});
}
//Choose iPhone carrier
function slideonlytwo(thechosentwo) {
$('.carrier').each(function(index) {
if ($(this).attr("id") == thechosentwo) {
$(this).slideDown(200);
}
else {
$(this).slideUp(600);
}
});
}
</script>
HTML:
iPhone 5
<div class="model" id="iphone5" style="display: none;padding: 15px;">
<table width="80%">
<center>
<tr>
<td width="33%"><a id="5carrier" href="javascript:slideonlytwo('5a');"><img src="_include/images/icons/att.png"></a>
<div class="carrier" id="5a" style="display:none;padding: 5px;"> Next Option.</div>
</td>
<td width="33%"><a id="5carrier" href="javascript:slideonlytwo('5v');"><img src="_include/images/icons/verizon.png"></a>
<div class="carrier" id="5v" style="display:none;padding: 5px;"> Next Option.</div>
</td>
<td width="33%"><a id="5carrier" href="javascript:slideonlytwo('5s');"><img src="_include/images/icons/sprint.png"></a>
<div class="carrier" id="5s" style="display:none;padding: 5px;"> Next Option.</div>
</td>
<td width="33%"><a id="5carrier" href="javascript:slideonlytwo('5f');"><img src="_include/images/icons/tmobile.png"></a>
<div class="carrier" id="5f" style="display:none;padding: 5px;"> Next Option.</div>
</td>
</tr>
</center>
</table>
</div>
</td>
<td width="33%">
<div>
<a id="myHeader" href="javascript:slideonlyone('iphone4s');" ><center><img src="_include/images/products/iphone4s.png">
<br><b>iPhone 4S</b><center></a></a>
</div>
<div class="model" id="iphone4s" style="display: none;padding: 15px;">
<table width="100%">
<tr>
<td width="33%">AT&T</td>
<td width="33%">Verizon</td>
<td width="33%">Sprint</td>
<td width="33%">Factory Unlocked</td>
</tr>
</table>
</div>
</td>
<td width="33%">
<div>
<a id="myHeader" href="javascript:slideonlyone('iphone4');" ><center><img src="_include/images/products/iphone4.png">
<br><b>iPhone 4</b><center></a></a>
</div>
<div class="model" id="iphone4" href="javascript:slideonlyone('4carrier)" style="display: none;padding: 15px;">
<table width="100%">
<tr>
<td width="33%">AT&T</td>
<td width="33%">Verizon</td>
<td width="33%">Sprint</td>
<td width="33%">Factory Unlocked</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</html>