你這個咋用?不過我解決了,用CSS+DIV,不用JS,也沒用SVG模式,這里分享出來吧,留給后面有緣人。
CSS代碼
- /*板塊收起與展開*/
- .toggle-container {
- display: inline-block;
- vertical-align: middle;
- margin-right: 5px;
- }
- .toggle-checkbox {
- position: absolute;
- opacity: 0;
- }
- .toggle-label {
- cursor: pointer;
- display: inline-block;
- -webkit-tap-highlight-color: transparent;
- }
- .toggle-switch {
- position: relative;
- width: 33px;
- height: 18px;
- background-color: #e0e0e0;
- border-radius: 11px;
- box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
- transition: all 0.3s ease;
- }
- .toggle-switch-handle {
- position: absolute;
- width: 16px;
- height: 16px;
- background-color: white;
- border-radius: 50%;
- top: 1px;
- left: 1px;
- box-shadow: 0 1px 3px rgba(0,0,0,0.2);
- transition: all 0.3s ease;
- }
- .toggle-checkbox:checked + .toggle-label .toggle-switch {
- background-color: #4285f4;
- }
- .toggle-checkbox:checked + .toggle-label .toggle-switch-handle {
- transform: translateX(15px);
- }
復制代碼 DIV代碼
- <!--板塊收起與展開-->
- <div class="toggle-container">
- <input type="checkbox" id="category_$cat[fid]_toggle" class="toggle-checkbox" checked>
- <label for="category_$cat[fid]_toggle"
- onclick="toggle_collapse('category_$cat[fid]');"
- class="toggle-label">
- <div class="toggle-switch">
- <span class="toggle-switch-handle"></span>
- </div>
- </label>
- </div></span>
復制代碼
|