Home >Web Front-end >CSS Tutorial >How to set border color in css
Method: 1. The border-color attribute sets the colors of the four borders at the same time; 2. The border-top-color, border-bottom-color, border-left-color, and border-right-color attributes are set separately. Top, bottom, left and right borders.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
css set border color
Method 1: Use the border-color attribute to set the color of four borders at the same time
The border-color property is a shorthand property that sets the color of the visible portion of all borders of an element.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style> .box{ width: 280px; height: 62px; border-style:solid; border-color: red; } </style> </head> <body> <div class="box">欢迎来到PHP中文网!</div> </body> </html>
Rendering:
Method 2: Set the upper, lower, left and right borders respectively
border-top-color property: top border color
border-bottom-color property: bottom border color
border- left-color attribute: left border color
border-right-color attribute: right border color
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style> .box{ width: 280px; height: 62px; border-style:solid; border-top-color:red; border-bottom-color:paleturquoise; border-left-color:palevioletred; border-right-color:darkcyan; } </style> </head> <body> <div class="box">欢迎来到PHP中文网!</div> </body> </html>
Rendering:
(Learning video sharing: css video tutorial)
The above is the detailed content of How to set border color in css. For more information, please follow other related articles on the PHP Chinese website!