📅  最后修改于: 2023-12-03 15:30:08.885000             🧑  作者: Mango
In CSS, a stroke refers to the outline or border of a shape or text element. The stroke
property can be used to set the color, width, and style of the stroke.
selector{
stroke: color width style;
}
color
: Specifies the color of the stroke. It can be specified using a keyword or a hexadecimal color value.width
: Specifies the width of the stroke in pixels or other length units.style
: Specifies the style of the stroke, such as solid, dashed, dotted, double, groove, ridge, inset, or outset.h1{
stroke: blue 2px solid;
}
This will add a blue stroke around the text of all h1
elements with a width of 2 pixels and a solid style.
div{
stroke: red 4px dashed;
}
This will add a red stroke around all div
elements with a width of 4 pixels and a dashed style.
p{
stroke: green 1px solid;
}
span{
stroke: orange 2px dotted;
}
a{
stroke: purple 3px double;
}
This example shows how different stroke styles can be applied to different elements on a page.
Stroke properties in CSS can add visual interest to text and shapes on a webpage. By understanding the syntax and available options for the stroke
property, developers can create custom effects to enhance the design of their site.