我发现了几篇关于如何确定边框的文章,但我试图做的是有点不同。CSS虚线和斜线边框
我有虚线边框的元素,像这样:
.box { border: 1px dashed #fff; }
不过,我试图同时拥有.box的元素及其虚线边框的边角成45度角。
这可能吗?
我发现了几篇关于如何确定边框的文章,但我试图做的是有点不同。CSS虚线和斜线边框
我有虚线边框的元素,像这样:
.box { border: 1px dashed #fff; }
不过,我试图同时拥有.box的元素及其虚线边框的边角成45度角。
这可能吗?
你可以通过调整边界半径的贝塞尔获得一些相当接近到45度角: http://www.css3.info/preview/rounded-border/
没错,尽管这不会达到完全的直线。 – gjunkie
是否有一个原因,为什么你会不想与2背景元素做到这一点?
.box {
/* this background image will stick to the top of the box */
background: url(/* you would put a 10px high image that is the width of said box */) no-repeat left top;
display: block;
padding: 10px 0 0; /* this padding element needs to match the background height */
}
.box .inner {
/* this will stick the background image to the bottom, and grow with the natural height of the box */
background: url(/* you'd put a looong background image, that could stretch vertically */) no-repeat left bottom;
display: block;
padding: 0 10px 10px;
}
您的标记应该是这样的:
<div class="box">
<div class="inner">
...Content goes here...
</div>
</div>
我能理解,如果你想只用border
风格做到这一点,但我不知道的方式做正确的角度和让它在IE中工作,要获得最大的认可。
感谢您的帮助。我想这样做的原因是因为我试图用虚线在博客文章周围有一个包裹元素,并且在它下面有一个看起来像这样的选项卡。如果我用图像制作破折号,那么匹配CSS生成的破折号将会更困难。 – gjunkie
所以你想“边缘”而不是破折号?或者你想整个盒子(和边框)旋转45度? –
我希望整个边界都是虚线,但是每个角都要成45度角,包括虚线。 – gjunkie