CSS邊框3D導(dǎo)航條可以讓網(wǎng)站的導(dǎo)航更加美觀,增強(qiáng)用戶體驗(yàn)。下面是一個(gè)實(shí)現(xiàn)CSS邊框3D導(dǎo)航條的例子:
CSS代碼: nav { display: flex; justify-content: center; } ul { list-style: none; margin: 0; padding: 0; } li { margin: 0; padding: 0; } a { display: block; color: #fff; text-align: center; text-decoration: none; padding: 18px 29px; font-size: 20px; font-weight: 700; border: 1px solid #fff; -webkit-box-shadow: 0px 0px 0px 2px rgba(255, 255, 255, 0.3); box-shadow: 0px 0px 0px 2px rgba(255, 255, 255, 0.3); position: relative; } a:before { content: ""; position: absolute; top: 0; left: -1px; height: 100%; width: 0; background: linear-gradient(to bottom, rgba(255, 255, 255, 0.45) 0%, rgba(0, 0, 0, 0.3) 100%); z-index: -1; transition: width 0.2s ease 0s; } a:hover:before { width: calc(100% + 2px); } a:hover { -webkit-box-shadow: 0px 0px 0px 2px rgba(255, 255, 255, 0.6); box-shadow: 0px 0px 0px 2px rgba(255, 255, 255, 0.6); } HTML代碼:
通過這種方式,可以實(shí)現(xiàn)比傳統(tǒng)導(dǎo)航更美觀的效果,同時(shí)也增加網(wǎng)站的可用性。