CSS上的边框高度 [英] Border Height on CSS

查看:202
本文介绍了CSS上的边框高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表TD,在它的右边,我想添加一个1像素边框,所以我这样做:

I have a table TD and on the right of it I want to add a 1 pixel border, so I've done this:

table td {
    border-right:1px solid #000;
}

它工作正常,但问题是边框的高度取整个TD的高度。

It works fine but the problem is that the border's height takes the total TD's height.

有没有办法设置边框的高度?

Is there a way to set the height of the border?

推荐答案

不,没有。边框总是和元素一样高。

No, there isn't. The border will always be as tall as the element.

您可以通过将单元格的内容包装在< span> ; ,并对其应用高度/边框样式。或者通过在1像素宽的PNG(它是正确的高度)上绘制一条短垂直线,并将其作为单元格的背景应用:

You can achieve the same effect by wrapping the contents of the cell in a <span>, and applying height/border styles to that. Or by drawing a short vertical line in an 1 pixel wide PNG which is the correct height, and applying it as a background to the cell:

background:url(line.png) bottom right no-repeat;

这篇关于CSS上的边框高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆