如何从列表中的最后一项删除样式?
我刚刚创建了这样的东西:
有什么方法可以删除最后一列末尾的行吗? (这是一个PHP while)
代码:
<div style="border-bottom: 1px solid #cdcdcd; margin-right: 10px; margin-bottom: 5px; font-size: 10px;">
<div name="gameicon" style="width: 16px; margin-left: 5px; float: left;">
<img src="images/games/<?php echo $games['short']; ?>.gif" alt="ICON" />
</div>
<div id="game" style="width: 115px; margin-left: 5px; float: left; text-align: right;">
<b><?php echo $games['game']; ?></b>
</div>
<div style="float: left; margin-left: 15px;">
<?php echo $signs_count; ?>
</div>
<div style="float: left; margin-left: 3px; margin-right: 3px;">/</div>
<div style="float: left; color: <?php echo $site_color; ?>;">
<b><?php echo $signs_count_paid; ?></b>
</div>
<div class="clearer"></div>
</div>
I've just created something like this:
Is there any way to remove the line from the end of the last colum? (it's a PHP while)
Code:
<div style="border-bottom: 1px solid #cdcdcd; margin-right: 10px; margin-bottom: 5px; font-size: 10px;">
<div name="gameicon" style="width: 16px; margin-left: 5px; float: left;">
<img src="images/games/<?php echo $games['short']; ?>.gif" alt="ICON" />
</div>
<div id="game" style="width: 115px; margin-left: 5px; float: left; text-align: right;">
<b><?php echo $games['game']; ?></b>
</div>
<div style="float: left; margin-left: 15px;">
<?php echo $signs_count; ?>
</div>
<div style="float: left; margin-left: 3px; margin-right: 3px;">/</div>
<div style="float: left; color: <?php echo $site_color; ?>;">
<b><?php echo $signs_count_paid; ?></b>
</div>
<div class="clearer"></div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:抱歉,我在您编辑代码之前就回答了。这个答案仍然适用,您只需更改 HTML 即可将 div 放入无序列表中。
您可以使用:
但是,某些浏览器不支持
last-child
选择器(例如IE7)。对first-child
选择器有更多支持。您可以选择的一个选项是将该边框添加到元素的顶部而不是底部,然后使用以下方法从顶部删除该边框:另一种选择是使用 jQuery 更改 CSS,这样您就知道它会起作用跨浏览器:
Edit: sorry, I answered before you edited in your code. This answer still applies, you would just have to change your HTML to place the div's in an unordered list.
You could use:
However, some browsers do not support the
last-child
selector (IE7, for example). There is more support for thefirst-child
selector. One option you do have is to add that border to the top of the elements instead of the bottom, and then remove that border from the top instead, using:Another option is to use jQuery to alter the CSS, so you know it will work cross-browser:
如果您将代码第一行从 :
更改为 :
CSS:
我希望这种方式会有所帮助。
what if you change your code , first line from :
To :
CSS:
I hope this way will be helpful.