如何在 CSS 中使用图像作为边框

发布于 2024-07-27 15:41:24 字数 99 浏览 2 评论 0原文

我想将表格的边框设置为“1px 纯黑色”,但底部除外,我想在底部使用提供链接指针的图像 - 作为视觉辅助。

当其他边框是常规CSS时,是否可以将图像设置为底部边框。

I want to set the border of a table to be "1px solid black" except on the bottom, where I want to use an image which provides a pointer into the link - as a visual aid.

Is it possible to set an image as the bottom border when the other borders are regular css.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

嘦怹 2024-08-03 15:41:24

尝试将表格放入

中,然后:

.myTableContainer{
  padding-bottom: 1px;
  background: url(myBorderImage.png) bottom left;
}

这应该适用于所有浏览器。

Try putting the table inside <div class="myTableContainer"></div> and then:

.myTableContainer{
  padding-bottom: 1px;
  background: url(myBorderImage.png) bottom left;
}

This should work well across all browsers.

留蓝 2024-08-03 15:41:24

CSS3 添加了对边框图像的支持。 您可以在 http://www.w3.org/TR/css3-background/# 找到更多信息边框图像。 此时(2012 年初),由于所有版本的 IE 都缺乏支持,它可能无法安全使用。 要跟踪何时可以安全使用,您可以访问 http://caniuse.com/#search=border-image 。 模拟边框图像样式的一种方法是使用定位的背景图像。 例如,要模拟顶部边框:

div
{
  background-image: url('topBorder.gif');
  background-position: top;
  background-repeat: repeat-x;
}

CSS3 has added support for border-image. You can find more information at http://www.w3.org/TR/css3-background/#border-images. At this point (early 2012), it's probably not safe to use due to lack of support in all versions of IE. To track when it is safe to use you can visit http://caniuse.com/#search=border-image. One way to simulate the border-image style is to use a positioned background-image. For example, to simulate a top border:

div
{
  background-image: url('topBorder.gif');
  background-position: top;
  background-repeat: repeat-x;
}
月寒剑心 2024-08-03 15:41:24

我不这么认为。 您最好添加一个

在表格下方,给它一个黑色边框,一个固定的背景,和一些固定的填充或诸如此类的东西(给它一些大小)。

I don't think so. You're probably better off adding a <DIV> below the table, give it a black border, a fixed background, and some fixed padding or whatnot (to give it some size).

流心雨 2024-08-03 15:41:24

一种解决方案是使用 CSS 中的背景图像设置元素的样式,然后在 CSS 中指定背景的偏移量。 背景可以从元素(例如 div 或 li 元素)的边缘伸出。 这可以用于许多不同的效果,其中之一是使用纯 CSS 的阴影外观。

这里有一些细节:

http://www.alistapart.com/articles/cssdropshadows/

One solution is to style your element with a background image in css and then specify an offset for the background in CSS. The background can poke out from beyond the edge of the element (a div or li element for example). This can be used for many different effects, one being the appearance of a drop shadow using pure css.

Some specifics here:

http://www.alistapart.com/articles/cssdropshadows/

你爱我像她 2024-08-03 15:41:24

现在有 CSS3border-image 属性,但它仍然不适用于所有浏览器。

好的,我们有一个关于此主题的 W3Schools 链接

Now there is CSS3 and a border-image property for that, but still it does not work for all browsers.

OK, let's there be a W3Schools link on this topic.

時窥 2024-08-03 15:41:24

不。您为什么不为此目的尝试另一个表行呢?

No. Why don't you try another table row for that purpose?

握住你手 2024-08-03 15:41:24

尝试在桌子下面放一个,然后将他的风格设置为“

.bottomborder {
  height:1px;
  background-image:url("yourImage.png");
}

应该很好”。

编辑:当然还有表格的上边框、左边框、右边框“solid 1px black”

Try putting a below your table then set his style like

.bottomborder {
  height:1px;
  background-image:url("yourImage.png");
}

Should work good.

Edit : and of course border-top, left, right for your table a "solid 1px black"

谈情不如逗狗 2024-08-03 15:41:24

您可以像这样设置边框,但底部边框除外:

border-top:1px solid black;
border-right:1px solid black;
border-left:1px solid black;

对于底部边框,您可以将图像设置为行的背景。

You can set the borders like that except the bottom border :

border-top:1px solid black;
border-right:1px solid black;
border-left:1px solid black;

For the bottom border, you can set your image as background of a row maybe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文