css⾥外边框与内边框_基本CSS边框
css⾥外边框与内边框
Every element can be provided with a basic border via , using one of 10 styles: none, hidden, solid, dashed, dotted, groove, ridge,  double, inset and outset. There are also three CSS3 border styles – wave, dot-dash, and dot-dot-dash – that are not yet supported in any browser.
可以通过使⽤以下10种样式之⼀为每个元素提供基本边框: none , hidden , solid , dashed , dotted , groove , ridge , double inset , inset和outset 。 还有3种CSS3边框样式( wave , dot-dash和dot-dot-dash在任何浏览器中均不⽀持。
The thickness of CSS borders is commonly defined in pixels, due to the fact that they are usually set to a “hairline” width in most site designs. Technically, border-width can be defined with any supported by the browser, with the exception of percentages. The hue of a border can also be defined using any , allowing for the possibility of semi-transparent borders.
CSS边框的厚度通常以像素为单位定义,因为⼤多数站点设计中通常将CSS边框的宽度设置为“细线”宽度。 从技术上讲,可以使⽤浏览器⽀持的任何来定义border-width (百分⽐除外)。 边框的⾊相也可以使⽤任何定义,从⽽允许使⽤半透明边框。
htmlborder
The most common way of defining borders is as a shortcut of space-separated values:
定义边界的最常见⽅法是将空格分隔的值作为快捷⽅式:
border:  style thickness color;
In the examples below I’ve added a small around of border-radius to show how the styles appear in a curve.
在下⾯的⽰例中,我在border-radius周围添加了⼀⼩部分,以显⽰样式在曲线中的显⽰⽅式。
border: 4px solid #222
边框:4px实线#222
border: 4px dashed #222
边框:4px虚线#222
border: 4px dotted #222
边框:点缀4px#222
border: 4px groove #777
边框:4px凹槽#777
border: 4px ridge #777
边框:4px脊#777
border: 4px double #222
边框:4px双#222
border: 4px inset #777
边框:4px嵌⼊#777
border: 4px outset #777
边框:开始时为4px#777
You’ll notice that double is particularly sensitive to thickness, distributing the amount given in the shor
tcut between the inner and outer edges and the space between them. ridge and groove are similarly sensitive to color, using derivatives of the hue set in the shortcut to tone the inner and outer edges. For that reason, using “pure” colors: white, black, some primary hues – is not suggested, as doing so diminishes the browser’s ability to create a decent visual effect. inset and outset are similarly limited, and look “hokey” unless applied subtly.
您会注意到, double对厚度特别敏感,它会将快捷⽅式中给定的数量分配在内外边缘之间以及它们之间的空间中。 ridge和groove对颜⾊也同样敏感,使⽤快捷⽅式中设置的⾊相的派⽣⾊调内外边缘。 因此,不建议使⽤“纯”颜⾊:⽩⾊,⿊⾊和⼀些主要⾊相,因为这样做会降低浏览器创建不错的视觉效果的能⼒。 inset和outset受到类似的限制,除⾮巧妙地应⽤,否则看起来像“ hokey”。
Borders can be applied to each side of an element separately using border-left, border-bottom, etc, using the same shortcut syntax. This can be broken down further: border-right-color and border-left-width, etc.
可以使⽤border-left , border-bottom等使⽤相同的快捷⽅式语法分别将border-left应⽤于元素的每⼀侧。 这可以进⼀步细分: border-right-color和border-left-width等。
To give one example where this level of detail might be used in a page, creating a Polaroid frame for
a photograph with borders as shown at the top of this article (in which the thickness of the bottom edge is different from the other three sides) might best be served by using CSS like the following:
举⼀个例⼦,可以在页⾯中使⽤这种详细程度,为带有边框的照⽚创建宝丽来相框,如本⽂顶部所⽰(底部边缘的厚度与其他三个侧⾯的厚度不同)最好通过使⽤CSS来实现,如下所⽰:
img#polaroid {
border: 25px solid #e8e8d3;
border-bottom-width: 50px;
}
Broadly speaking, has far greater control over border styles, but I will need to leave that for another article.
从⼴义上讲, 对边框样式有更⼤的控制权,但我需要在另⼀篇⽂章中进⾏介绍。
翻译⾃:
css⾥外边框与内边框

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。