Friday, July 8, 2016

border

http://learn.shayhowe.com/html-css/opening-the-box-model/

Borders

Borders fall between the padding and margin, providing an outline around an element. The border property requires three values: widthstyle, and color. Shorthand values for the border property are stated in that order—widthstylecolor. In longhand, these three values can be broken up into the border-widthborder-style, and border-color properties. These longhand properties are useful for changing, or overwriting, a single border value.
The width and color of borders can be defined using common CSS units of length and color, as discussed in Lesson 3.
Borders can have different appearances. The most common style values are solid,doubledasheddotted, and none, but there are several others to choose from.
Here is the code for a 6-pixel-wide, solid, gray border that wraps around all four sides of a <div>:
1
2
3
4
div {
  border: 6px solid #949599;
}

Borders Demo

Individual Border Sides

As with the margin and padding properties, borders can be placed on one side of an element at a time if we’d like. Doing so requires new properties: border-topborder-rightborder-bottom, and border-left. The values for these properties are the same as those of the border property alone: widthstyle, and color. If we want, we can make a border appear only on the bottom of an element:
1
2
3
4
div {
  border-bottom: 6px solid #949599;
}
Additionally, styles for individual border sides may be controlled at an even finer level. For example, if we wish to change only the width of the bottom border we can use the following code:
1
2
3
4
div {
  border-bottom-width: 12px;
}
These highly specific longhand border properties include a series of hyphen-separated words starting with the border base, followed by the selected side—topright,bottom, or left—and then widthstyle, or color, depending on the desired property.

Border Radius

While we’re looking at borders and their different properties, we need to examine theborder-radius property, which enables us to round the corners of an element.
The border-radius property accepts length units, including percentages and pixels, that identify the radius by which the corners of an element are to be rounded. A single value will round all four corners of an element equally; two values will round the top-left/bottom-right and top-right/bottom-left corners in that order; four values will round the top-lefttop-rightbottom-right, and bottom-left corners in that order.
When considering the order in which multiple values are applied to the border-radiusproperty (as well as the margin and padding properties), remember that they move in a clockwise fashion starting at the top left of an element.
1
2
3
4
div {
  border-radius: 5px;
}

Border Radius Demo

The border-radius property may also be broken out into longhand properties that allow us to change the radii of individual corners of an element. These longhand properties begin with border, continue with the corner’s vertical location (top orbottom) and the corner’s horizontal location (left or right), and then end with radius. For example, to change the top-right corner radius of a <div>, the border-top-right-radius property can be used.
1
2
3
4
div {
  border-top-right-radius: 5px;
}

Box Sizing

No comments:

Post a Comment