[CSS] Background
background-color
Transparency
opacity: 0.0 - 1.0. The lower value, the more transparentrgba: The alpha parameter is a number between 0.0 (fully transparent) and 1.0 (fully opaque).div {
background: rgba(0, 128, 0, 0.3); /* Green background with 30% opacity */
}
background-image
body {
background-color: #ffffff;
background-image: url('img_tree.png');
background-repeat: no-repeat;
background-position: right top;
background-attachment: fixed;
}
background-repeat: By default, thebackground-imageproperty repeats an image both horizontally and vertically.repeat-x(repeated only horizontally)no-repeat
background-attachment:scrollfixed
background-position
background (shorthand property)
Specify all the background properties in one single property.
body {
background: #ffffff url('img_tree.png') no-repeat right top;
}
When using the shorthand property the order of the property values is:
background-colorbackground-imagebackground-repeatbackground-attachmentbackground-position
圖片取代文字技巧:以 logo 為例
.header h1 a {
background-image: url(.../img/logo.png);
display: block;
text-indent: 101%;
overflow: hidden;
whitespace: nowrap;
}
text-indent: 101%;首行縮排over-flow: hidden;超出 div 寬度的話隱藏whitespace: nowrap;不斷行