CSS3 RGBA色彩模式使用实例讲解

2022-10-18,,,,

rgba色彩模式是rgb色彩模式的扩展,在红,蓝,绿三原色的基础上增加了不透明度参数。语法如下:

rgba(r,g,b,<opaciy>)

其中r,g,b表示红色,蓝色,绿色三种原色所占的比重。其值可以使整数或者百分数,正整数值的取值范围为0~255,百分数值的取值范围为0.0%~100.0%,超出范围的数值将被截止其最接近的取值极限。注意,并非所有的浏览器都支持使用百分数值。第四个参数<opacity>表示不透明度,取值在0到1之间。

实例:设计带有阴影边框的表单

xml/html code复制内容到剪贴板

  1. <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8" />  
  5. <title>rgba color</title>  
  6. <style type="text/css">  
  7. input, textarea {/*统一输入域样式*/   
  8.     padding: 4px;   
  9.     border: solid 1px #e5e5e5;   
  10.     outline: 0;   
  11.     font: normal 13px/100% verdana, tahoma, sans-serif;   
  12.     width: 200px;   
  13.     background: #ffffff;   
  14.     box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;/*设计边框阴影效果*/   
  15.     -moz-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;/*兼容mozilla类型的浏览器,如ff*/   
  16.     -webkit-box-shadow: rgba(0, 0, 0, 0.1) 0px 0px 8px;/*兼容webkit引擎,如chrome和safari*/     
  17. }   
  18. textarea {/*定义文本区域样式*/   
  19.     width: 400px;   
  20.     max-width: 400px;   
  21.     height: 150px;   
  22.     line-height: 150%;   
  23.     background:url(images/form-shadow.png) no-repeat bottom right;   
  24. }   
  25. input:hover, textarea:hover, input:focus, textarea:focus { border-color: #c9c9c9; }/*设计鼠标的动态效果*/   
  26. label {/*定义标签样式*/   
  27.     margin-left: 10px;   
  28.     color: #999999;   
  29.     display:block;/*以块状显示,实现分行显示*/   
  30. }   
  31. .submit input {/*设计提交按钮的样式*/   
  32.     width:auto;   
  33.     padding: 9px 15px;   
  34.     background: #617798;   
  35.     border: 0;   
  36.     font-size: 14px;   
  37.     color: #ffffff;   
  38. }   
  39. </style>  
  40. </head>  
  41.   
  42. <body>  
  43. <form>  
  44.     <p class="name">  
  45.         <label for="name">姓名</label>  
  46.         <input type="text" name="name" id="name" />  
  47.     </p>  
  48.     <p class="email">  
  49.         <label for="email">邮箱</label>       
  50.         <input type="text" name="email" id="email" />  
  51.     </p>  
  52.     <p class="web">  
  53.         <label for="web">个人网址</label>       
  54.         <input type="text" name="web" id="web" />  
  55.     </p>  
  56.     <p class="text">  
  57.         <label for="text">留言</label>  
  58.         <textarea name="text" id="text"></textarea>  
  59.     </p>  
  60.     <p class="submit">  
  61.         <input type="submit" value="提交" />  
  62.     </p>  
  63. </form>  
  64. </body>  
  65. </html>  

演示效果:

以上就是本文的全部内容,希望对大家的学习有所帮助。

《CSS3 RGBA色彩模式使用实例讲解.doc》

下载本文的Word格式文档,以方便收藏与打印。