純 CSS3 重現 Windows 7 開始選單視覺與交互,包含雙欄佈局、毛玻璃漸層、內/外陰影、圓角、懸停動畫。

⚠️ 請勿在 IE8 及以下瀏覽器查看,需 CSS3 支援。
線上 Demo:jankoatwarpspeed.com
作者提供設計草圖,明確雙欄結構:左側程式清單(白底、深色文字)、右側系統連結(深底、白字)、整體容器毛玻璃漸層邊框。

<div id="startmenu">
<ul id="programs">
<li><a href="#"><img src="firefox-32.png" alt=""> Mozilla Firefox</a></li>
<li><a href="#"><img src="chrome.png" alt=""> Google Chrome</a></li>
<li><a href="#"><img src="safari.png" alt=""> Safari</a></li>
<li><a href="#"><img src="opera.png" alt=""> Opera</a></li>
<li><a href="#"><img src="ie.png" alt=""> Internet Explorer</a></li>
<li><a href="#"><img src="rss_32.png" alt=""> RSS Feeds</a></li>
<li><a href="#"><img src="twitter_32.png" alt=""> Twitter</a></li>
<li><a href="#"><img src="delicious_32.png" alt=""> Delicious</a></li>
</ul>
<ul id="links">
<li class="icon"><img src="folder.png" alt=""></li>
<li><a href="#"><span>Documents</span></a></li>
<li><a href="#"><span>Pictures</span></a></li>
<li><a href="#"><span>Music</span></a></li>
<li><a href="#"><span>Computer</span></a></li>
<li><a href="#"><span>Network</span></a></li>
<li><a href="#"><span>Connect to</span></a></li>
</ul>
</div>
#startmenu:毛玻璃質感基座#startmenu {
border: solid 1px #102a3e;
overflow: visible;
display: inline-block;
margin: 60px 0 0 20px;
border-radius: 5px;
position: relative;
box-shadow: inset 0 0 1px #fff;
background-color: #619bb9; /* 降級色 */
background-image: linear-gradient(
to bottom,
rgba(50,123,165,0.75),
rgba(46,75,90,0.75) 50%,
rgba(92,176,220,0.75)
);
}
關鍵點:inline-block 包裹內容尺寸、overflow:visible 允許陰影溢出、多層 rgba() 漸層模擬 Aero 玻璃感。
#programs:白底卡片風#programs {
background: #fff;
border: solid 1px #365167;
margin: 7px 0 7px 7px;
border-radius: 3px;
box-shadow: 0 0 1px #fff;
}
#programs a {
display: block;
padding: 3px;
margin: 3px;
border: 1px solid transparent;
color: #4b4b4b;
text-decoration: none;
min-width: 220px;
border-radius: 3px;
transition: all 0.2s ease; /* 現代增強:平滑過渡 */
}
#programs a:hover {
border-color: #7da2ce;
box-shadow: inset 0 0 1px #fff;
background: linear-gradient(to bottom, #dcebfd, #c2dcfd);
}
#programs a img {
border: 0; vertical-align: middle; margin-right: 5px;
}
#links:深色系、側邊發光#links { margin: 7px; margin-top: -30px; } /* 負 margin 向上貼齊 */
#links li.icon { text-align: center; }
#links a {
display: block;
margin: 5px 0;
padding: 5px 10px;
border: 1px solid transparent;
color: #fff;
text-decoration: none;
min-width: 120px;
position: relative;
border-radius: 3px;
transition: all 0.2s ease;
}
#links a:hover {
border-color: #000;
box-shadow: inset 0 0 1px #fff;
background: linear-gradient(
to right,
rgba(81,115,132,0.55),
rgba(121,163,184,0.55) 50%,
rgba(81,115,132,0.55)
);
}
#links a span { display: block; padding: 5px; }
#links a:hover span {
background: linear-gradient(
to bottom,
transparent, transparent 49%,
rgba(2,37,58,0.5) 50%,
rgba(63,111,135,0.5)
);
}
亮點:span 疊加漸層實現懸停時「掃光」掃過效果;margin-top: -30px 讓右側欄視覺上與左側頂端對齊。
| 特性 | IE9+ | 現代瀏覽器 | IE6-8 降級建議 |
|---|---|---|---|
| border-radius | ✓ | ✓ | PIE.htc 或接受直角 |
| box-shadow | ✓ | ✓ | PIE.htc 或移除 |
| linear-gradient | ✓ (需 -ms-) | ✓ | 實心背景色降級 |
| rgba() | ✓ | ✓ | 十六進位色降級 |
| transition | ✓ (IE10+) | ✓ | 無動畫直接切換 |
backdrop-filter: blur(10px) 替代多層 rgba 漸層,真正實現毛玻璃效果。<button aria-expanded="false" aria-controls="startmenu"> + JS 切換 aria-expanded 與顯示狀態。Tab 切換項目、Enter/Space 執行、Esc 關閉、Arrow keys 方向導航。這個經典案例展示了 CSS3 視覺屬性(圓角、陰影、漸層)的綜合運用威力。雖然原始代碼針對 2010 年代瀏覽器,但其設計思維——層次分解、漸層模擬材質、陰影構建深度、狀態過渡增強交互——在現代 CSS 開發中依然完全適用。