小白教程
所有教程
关于
Search
172.70.100.101
172.70.100.101
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“HTML颜色”的源代码
本页内容
上一节:
HTML注释
下一节:
HTML_RGB_和_RGBA_颜色
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
[[Category:HTML教程|12]] HTML 颜色使用预定义的颜色名称或 RGB、HEX、HSL、RGBA 或 HSLA 值指定。 == 颜色名称 == 在 HTML 中,可以使用颜色名称来指定颜色: <html> <h1 style="background-color:Tomato;">Tomato</h1> <h1 style="background-color:Orange;">Orange</h1> <h1 style="background-color:DodgerBlue;">DodgerBlue</h1> <h1 style="background-color:MediumSeaGreen;">MediumSeaGreen</h1> <h1 style="background-color:Gray;">Gray</h1> <h1 style="background-color:SlateBlue;">SlateBlue</h1> <h1 style="background-color:Violet;">Violet</h1> <h1 style="background-color:LightGray;">LightGray</h1> </html> <sample title="" desc="" hererun="s"> <!DOCTYPE html> <html> <body> <h1 style="background-color:Tomato;">Tomato</h1> <h1 style="background-color:Orange;">Orange</h1> <h1 style="background-color:DodgerBlue;">DodgerBlue</h1> <h1 style="background-color:MediumSeaGreen;">MediumSeaGreen</h1> <h1 style="background-color:Gray;">Gray</h1> <h1 style="background-color:SlateBlue;">SlateBlue</h1> <h1 style="background-color:Violet;">Violet</h1> <h1 style="background-color:LightGray;">LightGray</h1> </body> </html> </sample> HTML 支持[[HTML颜色名称|140种标准颜色名称]] == 背景颜色 == 设置 HTML 元素的背景颜色 <html> <h1 style="background-color:DodgerBlue;">Hello World</h1> </html><sample title="" desc="" hererun="s3"> <h1 style="background-color:DodgerBlue;">Hello World</h1> </sample> == 文字颜色 == <h1 style="color:Tomato;">Hello World</h1> <sample title="" desc="" hererun="s4"> <h1 style="color:Tomato;">Hello World</h1> </sample> == 边框颜色 == <html> <h1 style="border:2px solid Tomato;">Hello World</h1> </html><sample title="" desc="" hererun="s5"> <h1 style="border:2px solid Tomato;">Hello World</h1> <h1 style="border:2px solid DodgerBlue;">Hello World</h1> <h1 style="border:2px solid Violet;">Hello World</h1> </sample> == 颜色值 == 在 HTML 中,还可以使用 RGB 值、HEX 值、HSL 值、RGBA 值和 HSLA 值来指定颜色。以下三个 <nowiki><div></nowiki> 元素的背景颜色设置为 RGB、HEX 和 HSL 值: <html> <h1 style="background-color:rgb(255, 99, 71);">rgb(255, 99, 71)</h1> <h1 style="background-color:#ff6347;">#ff6347</h1> <h1 style="background-color:hsl(9, 100%, 64%);">hsl(9, 100%, 64%)</h1> </html> 以下两个 <nowiki><div></nowiki> 元素的背景颜色设置为 RGBA 和 HSLA 值,这为颜色添加了一个 Alpha 通道(这里我们有 50% 的透明度): <html> <h1 style="background-color:rgba(255, 99, 71, 0.5);">rgba(255, 99, 71, 0.5)</h1> <h1 style="background-color:hsla(9, 100%, 64%, 0.5);">hsla(9, 100%, 64%, 0.5)</h1> </html> <sample title="" desc="" hererun="s7"> <h1 style="background-color:rgb(255, 99, 71);">...</h1> <h1 style="background-color:#ff6347;">...</h1> <h1 style="background-color:hsl(9, 100%, 64%);">...</h1> <h1 style="background-color:rgba(255, 99, 71, 0.5);">...</h1> <h1 style="background-color:hsla(9, 100%, 64%, 0.5);">...</h1> </sample>
返回至“
HTML颜色
”。
上一节:
HTML注释
下一节:
HTML_RGB_和_RGBA_颜色