|
你这个咋用?不过我解决了,用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>
复制代码
|
|