以下整理了一系列常見又實用的 CSS 設計技巧,涵蓋圓角、透明、漸層、對齊等熱門需求,都是實際專案中經常派上用場的片段。
.rec{
border-radius: 30px;
-moz-border-radius: 30px;
-webkit-border-radius: 30px;
}
.control{
opacity: 0.5;
-moz-opacity: 0.5;
filter: alpha(opacity=50);
}
#tbHandle th{
background: -webkit-linear-gradient(red, blue); /* Safari 5.1 - 6.0 */
background: -o-linear-gradient(red, blue); /* Opera 11.1 - 12.0 */
background: -moz-linear-gradient(red, blue); /* Firefox 3.6 - 15 */
background: linear-gradient(red, blue); /* 標準語法 */
}
此效果目前主要相容 IE 與 Chrome:
.icon a img{
filter: gray; /* for IE */
-webkit-filter: grayscale(100%); /* for Chrome */
}
.icon a:hover img{
filter: none;
-webkit-filter: grayscale(0%);
}
.title{
text-align: justify;
text-justify: inter-ideograph;
}
ul{
list-style: none;
margin-right: -10px;
zoom: 1; /* for ie7 */
}
ul li{
float: left;
margin-right: 10px;
}
.tb, .tb th, .tb td {
border: 1px dashed #ccc;
border-collapse: collapse;
}
.input360:focus{
border: 1px solid #7ecef4;
background: none;
}
這些技巧可以依需求自由組合,讓頁面的視覺表現與互動細節更加精緻。