暑期学习日记11:CSS颜色

1.CSS指定颜色是通过使用预定义的颜色名称,或 RGB、HEX、HSL、RGBA、HSLA 值设定CSS颜色

2.在 CSS 中,可以使用颜色名称来指定颜色:如:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
	<h1 style="background: tomato">tomato</h1>
	<h1 style="background: blue">blue</h1>
	<h1 style="background: red">red</h1>
	<h1 style="background: yellow">yellow</h1>
	<h1 style="background: green">green</h1>
</body>
</html>

显示效果为:

3.在 CSS 中,还可以使用 RGB 值、HEX 值、HSL 值、RGBA 值或者 HSLA 值来指定颜色:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<h1 style="background-color:tomato;">tomato</h1>
<h1 style="background-color:rgb(255, 99, 71);">tomato</h1>
<h1 style="background-color:#ff6347;">tomato</h1>
<h1 style="background-color:hsl(9, 100%, 64%);">tomato</h1>
</body>
</html>

显示效果为:

4.使用background设置CSS 背景颜色如第1例:

5.使用color设置CSS 文本颜色如:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
	<h1 style="color: tomato">tomato</h1>
	<h1 style="color: blue">blue</h1>
	<h1 style="color: red">red</h1>
	<h1 style="color: yellow">yellow</h1>
	<h1 style="color: green">green</h1>
</body>
</html>

 显示效果为:

 

6.使用solid设置CSS 边框颜色如:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
	<h1 style="border:2px solid tomato">tomato</h1>
	<h1 style="border:2px solid blue">blue</h1>
	<h1 style="border:2px solid red">red</h1>
	<h1 style="border:2px solid yellow">yellow</h1>
	<h1 style="border:2px solid green">green</h1>
</body>
</html>

显示效果为:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值