首页 > 其他分享 >css10 CSS Colors

css10 CSS Colors

时间:2024-05-29 21:56:00浏览次数:8  
标签:css10 color ut Colors values World Hello CSS

https://www.w3schools.com/css/css_colors.asp

 

Colors are specified using predefined color names, or RGB, HEX, HSL, RGBA, HSLA values.


CSS Color Names

In CSS, a color can be specified by using a predefined color name:

 

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

 


CSS/HTML support 140 standard color names.


CSS Background Color

You can set the background color for HTML elements:

<!DOCTYPE html>
<html>
<body>

<h1 style="background-color:DodgerBlue;">Hello World</h1>

<p style="background-color:Tomato;">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
</p>

</body>
</html>

 


Example

<h1 style="">Hello World</h1>
<p style="">Lorem ipsum...</p>

CSS Text Color

You can set the color of text:

Hello World

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Example

<h1 style="color:Tomato;">Hello World</h1>
<p style="color:DodgerBlue;">Lorem ipsum...</p>
<p style="color:MediumSeaGreen;">Ut wisi enim...</p>
<!DOCTYPE html>
<html>
<body>

<h3 style="color:Tomato;">Hello World</h3>

<p style="color:DodgerBlue;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>

<p style="color:MediumSeaGreen;">Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>

</body>
</html>

 


   

CSS Border Color

You can set the color of borders:

Hello World

Hello World

Hello World

Example

<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>
<!DOCTYPE html>
<html>
<body>

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

</body>
</html>

 


CSS Color Values

In CSS, colors can also be specified using RGB values, HEX values, HSL values, RGBA values, and HSLA values:

Same as color name "Tomato":

 

Same as color name "Tomato", but 50% transparent:

 

Example

<!DOCTYPE html>
<html>
<body>

<p>Same as color name "Tomato":</p>

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

<p>Same as color name "Tomato", but 50% transparent:</p>
<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>

<p>In addition to the predefined color names, colors can be specified using RGB, HEX, HSL, or even transparent colors using RGBA or HSLA color values.</p>

</body>
</html>

 

标签:css10,color,ut,Colors,values,World,Hello,CSS
From: https://www.cnblogs.com/emanlee/p/18221149

相关文章

  • css07 CSS Attribute Selectors
    https://www.w3schools.com/css/css_attribute_selectors.aspStyleHTMLElementsWithSpecificAttributesItispossibletostyleHTMLelementsthathavespecificattributesorattributevalues.CSS[attribute]SelectorThe[attribute]selectorisusedtos......
  • css08 How To Add CSS
    https://www.w3schools.com/css/css_howto.aspWhenabrowserreadsastylesheet,itwillformattheHTMLdocumentaccordingtotheinformationinthestylesheet.ThreeWaystoInsertCSSTherearethreewaysofinsertingastylesheet:ExternalCSSInte......
  • at-rule or selector expectedcss(css-ruleorselectorexpected)
    问题如图所示,在使用scss和less是使用//注释就会出现红色报错,这个不影响运行,但是看着很不舒服。解决没有找到什么好的解决办法,一般的解决方法是,把验证关闭,然后重启。但是后面我开启这个设置,再进行注释,没有报错,感觉还是重启的作用。先放着不管吧。......
  • 7. CSS 网格布局
    CSS3引入了强大的网格布局(GridLayout),它提供了一种二维的布局方式,使得创建复杂的网页布局变得更加简单和直观。通过定义行和列,我们可以精确控制网页元素的排列和对齐。本章将详细介绍网格布局的基本概念和属性,并通过具体示例帮助读者掌握如何使用网格布局。7.1网格布局简......
  • css06 CSS Pseudo-elements
    https://www.w3schools.com/css/css_pseudo_elements.aspWhatarePseudo-Elements?ACSSpseudo-elementisusedtostylespecifiedpartsofanelement.Forexample,itcanbeusedto:Stylethefirstletter,orline,ofanelementInsertcontentbefore,or......
  • 8. CSS弹性布局基础
    第8章弹性布局基础CSS3引入了一个强大的布局模块——弹性布局(Flexbox),它提供了一种更加高效、直观的方式来排列和对齐元素,使复杂布局的实现变得更加简单。本章将详细介绍弹性布局的基本概念和属性,并通过具体示例帮助读者掌握如何使用弹性布局。8.1弹性布局简介弹性布局(F......
  • 第三方css动画库
    https://animate.style///安装npminstallanimate.css--save//引入import'animate.css';//使用<h1class="animate__animatedanimate__bounce">Ananimatedelement</h1>//样式名称必须加animate__animated之后    ......
  • vite配置自动引入全局scss变量文件
    全局自动引入scss变量文件当定义了全局的scss变量文件并且而其他很多页面都需要使用的时候,都需要显式的使用@import或者@use引用一遍全局scss文件,很是麻烦。使用以下配置这样能有效避免造成大量重复工作,可以在任何scss文件中任意使用全局变量。定义全局scss变量文件配置vi......
  • CSS3 超实用属性:pointer-events (可穿透图层的鼠标事件)
    1、是什么pointer-events 直译为指针事件,该属性指定在什么情况下某个DOM可以成为鼠标事件的target。简而言之,就是允许/禁止DOM的鼠标事件(click事件、hover事件、mouse事件等鼠标事件)2、具体属性分析用法分析:pointer-events:auto|none|visiblePainted|visibleFill|......
  • css通过子元素选择父元素的实现示例
    在CSS中,直接通过子元素选择其父元素并不直接支持,因为CSS的选择器是从上到下(从父元素到子元素)进行选择的,而不是相反。但是,你可以使用其他方法或技术来间接实现这一效果,比如使用JavaScript、jQuery或其他脚本语言,或者通过调整你的HTML结构和CSS样式来达到类似的效果。不过,我可以给......