CSS

选择器

css中的选择器

背景颜色、图像

background background-attachment background-clip background-color background-image background-origin backgrond-position background-repeat background-size

文字、字体

color font font-family font-size font-size-adjust font-style font-variant font-weight

文档格式

hanging-punctuation hyphens letter-spacing line-height text-align text-decoration text-indent text-overflow text-shadow text-transform white-space word-spacing word-wrap

宽度和高度

width,height max-width min-width max-height min-height

外缘与内缘余白

margin margin-bottom margin-left margin-right margin-top padding padding-bottom padding-left padding-right padding-top

边框

border border-bottom border-color border-style border-width border-top border-right border-left

边框圆角

border-radius border-bottom-right-radius border-bottom-left-radius border-top-right-radius border-top-left-radius

边框图像

border-image border-image-repeat border-image-slice border-image-source border-image-width

容器与弹性容器

bottom clear clip box-decoration-break box-shadow align-content align-items align-self display flex-basis flex-direction flex-flow flex-grow flex-shrink flex-wrap justify-content float left outline-offset overflow overflow-x overflow-y order position right resize top vertical-align z-index

透明

opacity rgba

渐变

linear-gradient radial-gradient

文章分栏

break-after break-before break-inside columns column-count column-fill column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-width

时间过渡效果

transition transition-delay transition-duration transition-property transition-timing-function

动漫效果

@keyframes animation animation-delay animation-direction animation-duration animation-fill-mode animation-iteration-count animation-name animation-play-state animation-timing-function

2D、3D变形

transform translate matrix2d matrix3d perspective scale skew rotate transform-origin

颜色、尺寸、单位

角度与URL 颜色 单位长度

表格

border-collapse border-spacing caption-side empty-cells table-layout

列表

counter-increment counter-reset list-style list-style-type list-style-image list-style-position

基本的用户界面属性

box-sizing content cursor nav-index nav-left nav-down nav-right nav-up

CSS基础

更新时间:2014年10月10日

opacity(透明)

opacity: 值;

opacity: 0.5;

opacity属性指定元素box的整体透明度。

透明度使用0.0(完全透明)~1.0(完全不透明)之间的数值指定。透明效果适用于元素内的所有元素。

要想透明效果不适用于元素内的所有内容,例如背景颜色、边框的颜色单独需要透明时,可以使用rgba()指定。

opacity的值及其说明
属性 说明
opacity 0.5 0.0(完全透明)~1.0(完全不透明)之间的数值。
默认值:1
使用对象:所有元素
值的继承:不继承

使用例

.sample1,.sample2,.sample3,.sample4,.sample5,

.sample6,.sample7,.sample8,.sample9,.sample10,.sample11{

margin:10px;

}

.sample1 {background-color:blue;}

.sample2 {opacity:0.9; background-color:blue;}

.sample3 {opacity:0.8; background-color:blue;}

.sample4 {opacity:0.7; background-color:blue;}

.sample5 {opacity:0.6; background-color:blue;}

.sample6 {opacity:0.5; background-color:blue;}

.sample7 {opacity:0.4; background-color:blue;}

.sample8 {opacity:0.3; background-color:blue;}

.sample9 {opacity:0.2; background-color:blue;}

.sample10 {opacity:0.1; background-color:blue;}

.sample11 {opacity:0.0; background-color:blue;}

浏览器上的显示结果↓


使用默认值1:不透明
opacity:0.9;
opacity:0.8;
opacity:0.7;
opacity:0.6;
opacity:0.5;
opacity:0.4;
opacity:0.3;
opacity:0.2;
opacity:0.1;
opacity:0.0;
X

不同浏览器上的书写方法及对应情况

属性
opacity 9.0 4.0 2.0 3.1 9.0

注:IE8之前的版本支持filter属性,书写方式:filter:Alpha(opacity=50);

相关内容