color
设置字体颜色之前,我们首先了解color
在css
中有几种取值方式,一共有4种方式,若有不全还请在评论区告知谢谢,4种方式如下:class
属性值为.box
中的字体颜色设置为红色。代码块
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>设置字体颜色</title> <style> .box{ color: #ff0000; } </style> </head> <body> <h2 class="box">成功不是击败别人,而是改变自己</h2> </body> </html>
结果图
代码块
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>设置字体颜色</title> <style> .box{ color: rgb(250,0, 0) } </style> </head> <body> <h2 class="box">成功不是击败别人,而是改变自己</h2> </body> </html>
代码块
十进制表示颜色的方式在
css
中没有浏览器兼容性问题。
代码块
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>设置字体颜色</title> <style> .box{ color:red; } </style> </head> <body> <h2 class="box">成功不是击败别人,而是改变自己</h2> </body> </html>
结果图
代码块
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <title>设置字体颜色</title> <style> .box{ color: #f00; } </style> </head> <body> <h2 class="box">成功不是击败别人,而是改变自己</h2> </body> </html>
结果图
如对本文有疑问, 点击进行留言回复!!
css深入剖析transform的translate和perspective
HCIE第四天总结(典型组网之一:CSS+Eth-Trunk+iStack)
了解下Apache Elasticsearch 和 Kibana
网友评论