Home  >  Article  >  Web Front-end  >  How to set border color in css

How to set border color in css

青灯夜游
青灯夜游Original
2021-10-12 17:58:2916644browse

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.

How to set border color in css

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:

How to set border color in css

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:

How to set border color in css

(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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn