Skip to main content

CSS 切換開關產生器

使用視覺化編輯器建立自訂 CSS 切換開關。 調整大小、顏色和動畫,然後匯出程式碼。

#6366f1
#d1d5db
#ffffff

預覽

Wi-Fi
Bluetooth

HTML 程式碼

<label class="toggle-switch">
    <input type="checkbox" />
    <span class="slider"></span>
</label>

CSS 程式碼

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d1d5db;
    border-radius: 50px;
    transition: background-color 0.3s ease;
}

.toggle-switch .slider::before {
    content: "";
    position: absolute;
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
    background-color: #ffffff;
    border-radius: 45px;
    transform 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .slider {
    background-color: #6366f1;
}

.toggle-switch input:checked + .slider::before {
    transform: translateX(24px);
}
分享此工具
📖

使用方法

Step 1

選擇設計

選擇設計

選擇切換開關設計範本

Step 2

自訂設定

自訂設定

調整顏色、大小、圓角、動畫等

Step 3

複製程式碼

複製程式碼

複製 HTML/CSS 程式碼

功能特色

即時預覽

即時預覽切換開關的操作效果

多種樣式

設計變體:iOS 風格、Material 風格、扁平化等

流暢動畫

使用 CSS 過渡效果實現流暢的切換動畫

FAQ

將核取方塊樣式化為開關的 UI 元件。用於 ON/OFF 切換。