【发布时间】:2013-06-16 20:30:56
【问题描述】:
我正在尝试做一个从右到左的底部渐变。虽然我有这个工作,但对我来说毫无意义,而且微小的变化就会发生奇怪的事情。
从右到左给出正确的渐变
-webkit-border-image: -webkit-gradient( linear, 100% 100%, 0 0, from( #000000 ), to( #ffffff) ) 0 0 100% 0;
border-bottom-width: 5px;
这会将渐变置于 DIV 的背景中?!
-webkit-border-image: -webkit-gradient( linear, 100% 100%, 0 0, from( #000000 ), to( #ffffff) ) 0 0 0 0;
border-bottom-width: 5px;
以下是我了解和不了解的:
来自spec,它说:
-webkit-border-image: <function> <top> <right> <bottom> <left>
意思是:
<top> The distance from the top edge of the image.
<right> The distance from the right edge of the image.
<bottom> The distance from the bottom edge of the image.
<left> The distance from the left edge of the image.
所以,这意味着我的第一个 0 0 100% 0 应该具有距底部 100% 远离 的边框图像(即渐变)!但它恰恰相反。相反,它是唯一显示底部边框渐变的,所以它离底部实际上是 0。
为什么为所有这些值设置0 会使渐变成为 div 的背景?实际上,如果 div 有一个background-color,那么将border-image 的top、right、bottom 和left 都设置为0 会在背景颜色上绘制border渐变!
这一切是如何运作的?
工作示例(您可以将其更改为不同的值)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Abbott RealTime</title>
<style>
.test
{
position: relative;
top: 0px;
left: 0px;
width: 300px;
height: 200px;
margin:0;
padding:0;
border:0;
outline:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
background-color: #ffcc33;
/* This shows the bottom border properly */
-webkit-border-image: -webkit-gradient( linear, 100% 100%, 0 0, from( #000000 ), to( #ffffff) ) 0 0 100% 0;
/* This one would show the gradient in the background and the border as the background color! */
/*-webkit-border-image: -webkit-gradient( linear, 100% 100%, 0 0, from( #000000 ), to( #ffffff) ) 0 0 100% 0;*/
border-bottom-width: 5px;
}
</style>
</head>
<body>
<div class="test">test</div
</body>
</html>
【问题讨论】:
标签: html css google-chrome webkit