Стилизация чекбоксов на чистом CSS
Неплохая стилизация чекбоксов, которая выполнена на чистом CSS
Для начала посмотрите ДЕМО
Установка
1#: В самый низ вашего CSS вставьте:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
.card { --background: #fff; --background-checkbox: #0082ff; --background-image: #fff, rgba(0, 107, 175, 0.2); --text-color: #666; --text-headline: #000; --card-shadow: #0082ff; --card-height: 190px; --card-width: 190px; --card-radius: 12px; --header-height: 47px; --blend-mode: overlay; --transition: 0.15s; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .card:nth-child(odd) .card__body-cover-image { --x-y1: 100% 90%; --x-y2: 67% 83%; --x-y3: 33% 90%; --x-y4: 0% 85%; } .card:nth-child(even) .card__body-cover-image { --x-y1: 100% 85%; --x-y2: 73% 93%; --x-y3: 25% 85%; --x-y4: 0% 90%; } .card__input { position: absolute; display: block; outline: none; border: none; background: none; padding: 0; margin: 0; -webkit-appearance: none; } .card__input:checked ~ .card__body { --shadow: 0 0 0 3px var(--card-shadow); } .card__input:checked ~ .card__body .card__body-cover-checkbox { --check-bg: var(--background-checkbox); --check-border: #fff; --check-scale: 1; --check-opacity: 1; } .card__input:checked ~ .card__body .card__body-cover-checkbox--svg { --stroke-color: #fff; --stroke-dashoffset: 0; } .card__input:checked ~ .card__body .card__body-cover:after { --opacity-bg: 0; } .card__input:checked ~ .card__body .card__body-cover-image { --filter-bg: grayscale(0); } .card__input:disabled ~ .card__body { cursor: not-allowed; opacity: 0.5; } .card__input:disabled ~ .card__body:active { --scale: 1; } .card__body { display: grid; grid-auto-rows: calc(var(--card-height) - var(--header-height)) auto; background: var(--background); height: var(--card-height); width: var(--card-width); border-radius: var(--card-radius); overflow: hidden; position: relative; cursor: pointer; box-shadow: var(--shadow, 0 4px 4px 0 rgba(0, 0, 0, 0.02)); -webkit-transition: box-shadow var(--transition), -webkit-transform var(--transition); transition: box-shadow var(--transition), -webkit-transform var(--transition); transition: transform var(--transition), box-shadow var(--transition); transition: transform var(--transition), box-shadow var(--transition), -webkit-transform var(--transition); -webkit-transform: scale(var(--scale, 1)) translateZ(0); transform: scale(var(--scale, 1)) translateZ(0); } .card__body:active { --scale: 0.96; } .card__body-cover { --c-border: var(--card-radius) var(--card-radius) 0 0; --c-width: 100%; --c-height: 100%; position: relative; overflow: hidden; } .card__body-cover:after { content: ""; position: absolute; left: 0; top: 0; width: var(--c-width); height: var(--c-height); border-radius: var(--c-border); background: -webkit-gradient(linear, left top, right bottom, from(var(--background-image))); background: linear-gradient(to bottom right, var(--background-image)); mix-blend-mode: var(--blend-mode); opacity: var(--opacity-bg, 1); -webkit-transition: opacity var(--transition) linear; transition: opacity var(--transition) linear; } .card__body-cover-image { width: var(--c-width); height: var(--c-height); -o-object-fit: cover; object-fit: cover; border-radius: var(--c-border); -webkit-filter: var(--filter-bg, grayscale(1)); filter: var(--filter-bg, grayscale(1)); -webkit-clip-path: polygon(0% 0%, 100% 0%, var(--x-y1, 100% 90%), var(--x-y2, 67% 83%), var(--x-y3, 33% 90%), var(--x-y4, 0% 85%)); clip-path: polygon(0% 0%, 100% 0%, var(--x-y1, 100% 90%), var(--x-y2, 67% 83%), var(--x-y3, 33% 90%), var(--x-y4, 0% 85%)); } .card__body-cover-checkbox { background: var(--check-bg, var(--background-checkbox)); border: 2px solid var(--check-border, #fff); position: absolute; right: 10px; top: 10px; z-index: 1; width: 28px; height: 28px; border-radius: 50%; opacity: var(--check-opacity, 0); transition: transform var(--transition), opacity calc(var(--transition) * 1.2) linear, -webkit-transform var(--transition) ease; -webkit-transform: scale(var(--check-scale, 0)); transform: scale(var(--check-scale, 0)); } .card__body-cover-checkbox--svg { width: 13px; height: 11px; display: inline-block; vertical-align: top; fill: none; margin: 7px 0 0 5px; stroke: var(--stroke-color, #fff); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 16px; stroke-dashoffset: var(--stroke-dashoffset, 16px); -webkit-transition: stroke-dashoffset 0.4s ease var(--transition); transition: stroke-dashoffset 0.4s ease var(--transition); } .card__body-header { height: var(--header-height); background: var(--background); padding: 0 10px 10px 10px; } .card__body-header-title { color: var(--text-headline); font-weight: 700; margin-bottom: 8px; } .card__body-header-subtitle { color: var(--text-color); font-weight: 500; font-size: 13px; } |
2#: Следующий HTML код вставьте на нужных страницах между тегами <body> и </body>:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
<div class="grid"> <label class="card"> <input class="card__input" type="checkbox"/> <div class="card__body"> <div class="card__body-cover"><img class="card__body-cover-image" src="/img/category-a.png"/><span class="card__body-cover-checkbox"> <svg class="card__body-cover-checkbox--svg" viewBox="0 0 12 10"> <polyline points="1.5 6 4.5 9 10.5 1"></polyline> </svg></span></div> <header class="card__body-header"> <h2 class="card__body-header-title">Category A</h2> <p class="card__body-header-subtitle">Motorcycles</p> </header> </div> </label> <label class="card"> <input class="card__input" type="checkbox"/> <div class="card__body"> <div class="card__body-cover"><img class="card__body-cover-image" src="/img/category-b.png"/><span class="card__body-cover-checkbox"> <svg class="card__body-cover-checkbox--svg" viewBox="0 0 12 10"> <polyline points="1.5 6 4.5 9 10.5 1"></polyline> </svg></span></div> <header class="card__body-header"> <h2 class="card__body-header-title">Category B</h2> <p class="card__body-header-subtitle">Cars and ATVs</p> </header> </div> </label> <label class="card"> <input class="card__input" type="checkbox"/> <div class="card__body"> <div class="card__body-cover"><img class="card__body-cover-image" src="/img/category-c.png"/><span class="card__body-cover-checkbox"> <svg class="card__body-cover-checkbox--svg" viewBox="0 0 12 10"> <polyline points="1.5 6 4.5 9 10.5 1"></polyline> </svg></span></div> <header class="card__body-header"> <h2 class="card__body-header-title">Category C</h2> <p class="card__body-header-subtitle">Large goods vehicle</p> </header> </div> </label> <label class="card"> <input class="card__input" type="checkbox"/> <div class="card__body"> <div class="card__body-cover"><img class="card__body-cover-image" src="/img/category-d.png"/><span class="card__body-cover-checkbox"> <svg class="card__body-cover-checkbox--svg" viewBox="0 0 12 10"> <polyline points="1.5 6 4.5 9 10.5 1"></polyline> </svg></span></div> <header class="card__body-header"> <h2 class="card__body-header-title">Category D</h2> <p class="card__body-header-subtitle">Buses</p> </header> </div> </label> <label class="card"> <input class="card__input" type="checkbox"/> <div class="card__body"> <div class="card__body-cover"><img class="card__body-cover-image" src="/img/category-t.png"/><span class="card__body-cover-checkbox"> <svg class="card__body-cover-checkbox--svg" viewBox="0 0 12 10"> <polyline points="1.5 6 4.5 9 10.5 1"></polyline> </svg></span></div> <header class="card__body-header"> <h2 class="card__body-header-title">Category T</h2> <p class="card__body-header-subtitle">Tractors and SMV</p> </header> </div> </label> <label class="card"> <input class="card__input" type="checkbox" disabled="disabled"/> <div class="card__body"> <div class="card__body-cover"><img class="card__body-cover-image" src="/img/other.png"/><span class="card__body-cover-checkbox"> <svg class="card__body-cover-checkbox--svg" viewBox="0 0 12 10"> <polyline points="1.5 6 4.5 9 10.5 1"></polyline> </svg></span></div> <header class="card__body-header"> <h2 class="card__body-header-title">Other</h2> <p class="card__body-header-subtitle">Additional categories</p> </header> </div> </label> </div> |
Осталось лишь залить три картинки из прикреплённого архива в папку img