Welcome~歡迎來到「30天前端設計之旅」的DAY 25!今天我們將繼續深入探索創意按鈕設計的領域,學習如何設計帶有背景色與箭頭、增加視窗效果的按鈕,以及如何在按鈕的背景和邊角添加三角形箭頭和圓形箭頭的設計。這些技巧將大大提升按鈕的互動性和視覺吸引力,使網站的使用者體驗更加豐富。
D-25的學習目標:
<button class="arrow-btn">點擊這裡 <span class="arrow">→</span></button>
.arrow-btn {
padding: 10px 20px;
font-size: 1em;
background-color: #5e9ca0;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
position: relative;
transition: background 0.3s ease;
}
.arrow-btn .arrow {
margin-left: 10px;
transition: transform 0.3s ease;
}
.arrow-btn:hover .arrow {
transform: translateX(5px); /* 當按鈕被滑鼠懸停時,箭頭向右移動 */
}
<button class="new-window-btn" onclick="window.open('https://example.com')">新增視窗</button>
.new-window-btn {
padding: 10px 20px;
font-size: 1em;
background-color: #b8a29c;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background 0.3s ease;
}
.new-window-btn:hover {
background-color: #8c8a83;
}
<button class="corner-arrow-btn">了解更多</button>
.corner-arrow-btn {
position: relative;
padding: 10px 20px;
font-size: 1em;
background-color: #f0c987;
color: white;
border: none;
cursor: pointer;
}
.corner-arrow-btn::after {
content: '';
position: absolute;
top: 0;
right: 0;
width: 0;
height: 0;
border-left: 15px solid transparent;
border-bottom: 15px solid #b8a29c;
}
<button class="circle-arrow-btn"><span class="circle-arrow">→</span></button>
.circle-arrow-btn {
width: 50px;
height: 50px;
background-color: #5e9ca0;
color: white;
border: none;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: background 0.3s ease;
}
.circle-arrow-btn:hover {
background-color: #8c8a83;
}
.circle-arrow {
font-size: 1.5em;
}