CSS 背景色漸層設定 linear-gradient

From: https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient

HTML

<div id='background_div'
style='width:200px;height:200px;border:1px solid black;padding:5px;'>
我的背景色是漸層喔!
</div>

CSS

#background_div {
background-color: #F07575; /* fallback color if gradients are not supported */
background-image: -webkit-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For Chrome and Safari */
background-image: -moz-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For old Fx (3.6 to 15) */
background-image: -ms-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For pre-releases of IE 10*/
background-image: -o-linear-gradient(top, hsl(0, 80%, 70%), #bada55); /* For old Opera (11.1 to 12.0) */
background-image: linear-gradient(to bottom, hsl(0, 80%, 70%), #bada55); /* Standard syntax; must be last */
}

範例結果:
http://jsfiddle.net/UzKX2/

CSS 如何指定顏色 (16進位值、RGB、RGBA、HSL、HSLA)

From: http://www.w3schools.com/cssref/css_colors_legal.asp

Hexadecimal Colors

Hexadecimal color values are supported in all major browsers.

A hexadecimal color is specified with: #RRGGBB, where the RR (red), GG (green) and BB (blue) hexadecimal integers specify the components of the color. All values must be between 0 and FF.

For example, the #0000ff value is rendered as blue, because the blue component is set to its highest value (ff) and the others are set to 0.

Example

Define different HEX colors:

#p1 {background-color:#ff0000;} / * red */
#p2 {background-color:#00ff00;} / * green */
#p3 {background-color:#0000ff;} / * blue */

RGB Colors

RGB color values are supported in all major browsers.

An RGB color value is specified with: rgb(red, green, blue). Each parameter (red, green, and blue) defines the intensity of the color and can be an integer between 0 and 255 or a percentage value (from 0% to 100%).

For example, the rgb(0,0,255) value is rendered as blue, because the blue parameter is set to its highest value (255) and the others are set to 0.

Also, the following values define equal color: rgb(0,0,255) and rgb(0%,0%,100%).

Example

Define different RGB colors:

#p1 {background-color:rgb(255,0,0);} / * red */
#p2 {background-color:rgb(0,255,0);} / * green */
#p3 {background-color:rgb(0,0,255);} / * blue */

RGBA Colors

RGBA color values are supported in IE9+, Firefox 3+, Chrome, Safari, and in Opera 10+.

RGBA color values are an extension of RGB color values with an alpha channel – which specifies the opacity of the object.

An RGBA color value is specified with: rgba(red, green, blue, alpha). The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).

Example

Define different RGB colors with opacity:

#p1 {background-color:rgba(255,0,0,0.3);} / * red with opacity */
#p2 {background-color:rgba(0,255,0,0.3);} / * green with opacity */
#p3 {background-color:rgba(0,0,255,0.3);} / * blue with opacity */

HSL Colors

HSL color values are supported in IE9+, Firefox, Chrome, Safari, and in Opera 10+.

HSL stands for hue, saturation, and lightness – and represents a cylindrical-coordinate representation of colors.

An HSL color value is specified with: hsl(hue, saturation, lightness).

Hue is a degree on the color wheel (from 0 to 360) – 0 (or 360) is red, 120 is green, 240 is blue. Saturation is a percentage value; 0% means a shade of gray and 100% is the full color. Lightness is also a percentage; 0% is black, 100% is white.

Example

Define different HSL colors:

#p1 {background-color:hsl(120,100%,50%);} / * green */
#p2 {background-color:hsl(120,100%,75%);} / * light green */
#p3 {background-color:hsl(120,100%,25%);} / * dark green */
#p4 {background-color:hsl(120,60%,70%);} / * pastel green */

HSLA Colors

HSLA color values are supported in IE9+, Firefox 3+, Chrome, Safari, and in Opera 10+.

HSLA color values are an extension of HSL color values with an alpha channel – which specifies the opacity of the object.

An HSLA color value is specified with: hsla(hue, saturation, lightness, alpha), where the alpha parameter defines the opacity. The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).

Example

Define different HSL colors with opacity:

#p1 {background-color:hsla(120,100%,50%,0.3);} / * green with opacity */
#p2 {background-color:hsla(120,100%,75%,0.3);} / * light green with opacity */
#p3 {background-color:hsla(120,100%,25%,0.3);} / * dark green with opacity */
#p4 {background-color:hsla(120,60%,70%,0.3);} / * pastel green with opacity */

[轉貼] a:link / a:visited / a:hover / a:active 使用上的順序

來源:http://www.dotblogs.com.tw/joysdw12/archive/2011/01/07/20651.aspx

在網站超連結效果使用上常常用到 a:link / a:visited / a:hover / a:active 這幾個css屬性。但是在使用上必須注意到的是這些屬性是有順序的。

使用上的順序如下:

        /* 未連結 */
        a:link
        {
            color: #000000;
        }
        /* 已連結過 */
        a:visited
        {
            color: #FF0000;
        }
        /* 滑鼠移至連結 */
        a:hover
        {
            color: #00FF00;
        }
        /* 選擇的連結 */
        a:active
        {
            color: #0000FF;
        }
 

a:hover 需放置在 a:link 跟 a:visited 之後,則 a:active 放置在 a:hover 之後。

Partial URLs are interpreted relative to the source of the style sheet

6.4 URL

A Uniform Resource Locator (URL) is identified with a functional notation:

BODY { background: url(http://www.bg.com/pinkish.gif) }
The format of a URL value is ‘url(‘ followed by optional white space followed by an optional single quote (‘) or double quote (“) character followed by the URL itself (as defined in [11]) followed by an optional single quote (‘) or double quote (“) character followed by optional whitespace followed by ‘)’. Quote characters that are not part of the URL itself must be balanced.

Parentheses, commas, whitespace characters, single quotes (‘) and double quotes (“) appearing in a URL must be escaped with a backslash: ‘\(‘, ‘\)’, ‘\,’.

Partial URLs are interpreted relative to the source of the style sheet, not relative to the document:

BODY { background: url(yellow) }

Style a Select Box Using Only CSS

From: http://bavotasan.com/2011/style-select-box-using-only-css/

<div class="styled-select">
<select>
<option>Here is the first option</option>
<option>The second option</option>
</select>
</div>

.styled-select select {
background: transparent;
width: 268px;
padding: 5px;
font-size: 16px;
line-height: 1;
border: 0;
border-radius: 0;
height: 34px;
-webkit-appearance: none;
}

div 包在 select 標籤外

Here’s a quick way to style an input button

From: http://www.red-team-design.com/style-an-input-button

Here’s a quick way to style an input button
October 23, 2009 by Catalin Rosu – 12 comments
I assume there was at least one time when you wanted to add more appeal to a html input and at that moment you didn’t knew how.
We all know how boring looks an input when we use it without styling it and that’s why today I will show you the way to get rid of this old-style input.

For the beginning here is how a non-styled input looks like:

When styling and input button, we have two alternatives, to style it using only CSS with pout a background image, or using a custom background image.
1.USE ONLY CSS WITHOUT BACKGROUND IMAGE
First add a class or an id to your button. For this tutorial we will add an id because we do not intend to use this kind of button several times into a page:

Now let’s add some styles for the id:

#btn
{
border: 1px solid #777777;
background: #6e9e2d;
color: white;
font: bold 11px ‘Trebuchet MS’;
padding: 4px;
cursor: pointer;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
}
The final result looks like this:

 

Please note that border-radius actually is working only on Mozilla/Firefox, Google Chrome and Safari 3.

2.USE A CUSTOM BACKGROUND IMAGE
Start by creating a new .psd file with 78x28px size. From the left panel choose “Rounded Rectangle Tool” (ALT+U for Windows Users) and set a 4px radius.Fill it with #6e9e2d (green) color and apply some effects.

This is my result and also this is the Photoshop source file (please use it as you wish).

Download Photoshop FREE source file

 

Now, back to our code ….this image is 78x28px and we will use it as background image for our input.Here you have the new css code for it.
Note that this time you don’t need to use the value attribute anymore.

#btn
{
background: url(test-button-2.png);
cursor: pointer;
width: 78px;
height: 28px;
display: block;
border: none;
}
That’s it, i hope you’ll find it useful!

k9copy 將雙層DVD影片(D9)備份成單層DVD(縮片+防拷)

K9Copy

K9Copy 是一個自由、開源的DVD備份和DVD製作程式用於Unix-like操作系統 ,如 Linux和BSD 。許可遵從GNU General Public License。

功能

K9Copy 提供幾種方法來備份 DVD和利用libdvdcss規避CSS 防拷技術[1]

此軟體在用戶的電腦提供DVD刻錄機,可以直接備份單層的 DVD-5 。同樣,直接備份雙層的DVD-9是需要雙層DVD刻錄機。

K9Copy能夠將雙層DVD-9的內容移到一個單層DVD-5 。介面允許用戶以明確保留或丟棄任何來自原來光盤的內容,如視頻標題、音軌、字幕和DVD菜單。所有選定的備份內容壓縮到一個配置的檔案大小 ( 默認情況下4400 MB),並存儲在用戶的硬盤驅動器作成一個ISO 映像檔案或DVDVIDEO TS的檔案夾。K9Copy 可以轉換的備份數據到空白的DVD ± R媒體本身或利用外部DVD製作軟體,如K3b完成這項任務。[1] 此外, K9Copy 製作出的 ISO映像檔案可以使用任何軟體記錄到DVD,在任何平台都能夠記錄 ISO映像到光盤。

經實地操作證實能將影音DVD出租店所租到的雙層DVD,透過k9copy轉成單層DVD光碟映像檔。

from:http://zh.wikipedia.org/wiki/K9Copy

CSS 背景透明 文字不透明

在 IE 上指定 css opacity 屬性,可以讓容器的背景顏色變的透明。但被包在此一容器上的子元素,他們的文字、邊框、背景色也會受透明度的影響。要讓子元素不受父元素透明度的影響,可以在子元素上指定 css position 屬性為 relative 或是 absolute 。

有些 Browsers 已有支援 css RGBa 屬性。就可以直接用 css RGBa 屬性設定透明度,如此被包在裏面的子元素的顯示,就不會受到父元素透明度的影響而變得有些透明。

Browser, Version, Platform Outcome Fallback
Mozilla Firefox 3.x (and up) Works
Mozilla Firefox 2.x (and down) Doesn’t Work Solid Color
Google Chrome (any version) Works
WebKit – Safari 3.x (and up) Works
WebKit – Safari 2.x (and down) Doesn’t Work
Mobile Safari (iPhone / iPod Touch / iPad) Works
Opera 10.x (and up) Works
Opera 9.x (and down) Doesn’t Work Solid Color
Internet Explorer 9 Preview Works
Internet Explorer 8 (down to 6) Doesn’t Work Solid Color
Internet Explorer 5.5 (and down) Doesn’t Work No Color
Netscape (any version) Doesn’t Work Solid Color
BlackBerry Storm Browser Works
  • IE9 已支援 RGBa 要記註喔!
  • 在 IE 上被設定為背景透明的父容器,如果它的 css: position 屬性為 absolute 時。請不要再指定 css: z-index 屬性給它。因為這樣會讓子元素不受父容器透明度影響的設定無效。如果頁面上有多個容器為透明背景且position:absolute,請將要放置最下層容器HTML代碼寫在其它容器元素代碼之前。

用 jQuery 判斷透明度是要用「opacity」、還是「RGBa」。

$(function () {
            if ($.browser.msie && $.browser.version < 9.0) { //不包含ie9

                $(".fixed_block").css({ opacity: "0.4", "background-color": "white" });
                $("#i_menu,#top_menu").css({ opacity: "0.7", "background-color": "white" });
            }
            else {
                $(".fixed_block").css({ background: "rgba(255, 255, 255, 0.4)" });
                $("#i_menu,#top_menu").css({ background: "rgba(255, 255, 255, 0.7)" });
            }
        });

參考來源:
RGBa Browser Support

Css span 設定寬度無效 指定 display:inline-block 讓設定有效

Span 標籤預設是無法指定寬度屬性的,想要讓寬度屬性可以起作用必須要將display設定成inline-block。

指定width屬性無效
指定width屬性有效

<span style="background-color: yellow; width: 250px;">指定width屬性無效</span>
<span style="background-color: yellow; width: 250px; display: inline-block;">指定width屬性有效</span>