Стеклянные иконки на CSS3
Отличное исполнение стеклянного стиля для кнопочек. Всё выполнено на чистом CSS3
Для начала посмотрите ДЕМО
Установка:
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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
.centered { height: 100%; text-align: center; } .left { float: left; padding: 20px; } .right { float: right; padding: 20px; } .vert { position: relative; top: 50%; transform: translateY(-50%); } .content { width: 100%; height: 100%; padding: 0; margin: 0; background-repeat: no-repeat; z-index: 0; } /* Buttons Start Here */ .button { position: relative; color: rgba(255, 255, 255, 0.6); font-size: 16px; text-decoration:none; padding: 0.5em 1.5em; margin: 0.5em; cursor: pointer; width: 200px; height: 40px; border-radius: 8px; -webkit-border-radius: 8px; -moz-border-radius: 8px; -webkit-transition: all 0.1s ease-in-out; -moz-transition: all 0.1s ease-in-out; -o-transition: all 0.1s ease-in-out; transition: all 0.1s ease-in-out; outline: 0; } div.button { line-height: 20px; height: 25px; width: 200px; padding-left: 0; padding-right: 0; margin-left: auto; margin-right: auto; } button:active { -webkit-transition: none !important; -moz-transition: none !important; -o-transition: none !important; transition: none !important; } .glass { background: linear-gradient( to bottom, rgba(180,180,180,0.8) 0%, rgba(180,180,180,0.5) 3%, rgba(180,180,180,0.1) 45%, rgba(0,0,0,0) 0%, rgba(0,0,0,0.3) 28%, rgba(0,0,0,0.3) 60%, rgba(0,0,0,0.3) 65%, rgba(255,255,255,0.3) 90%, rgba(0,0,0,0.3) 95%, rgba(0,0,0,0.3) 100% ); /* W3C */ border-color: rgba(0, 0, 0, 0.6); border-image: none; border-style: solid; border-width: 0px; box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.4) inset, 0 2px 6px rgba(0, 0, 0, 0.5), 0 10px rgba(0, 0, 0, 0.05) inset; } .glass2 { background: linear-gradient( 170deg, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0.6) 20%, rgba(255,255,255,0.1) 50%, rgba(0,0,0,0.0) 50%, rgba(0,0,0,0.0) 100% ); /* W3C */ border-color: rgba(255, 255, 255, 0.4); border-image: none; border-style: inset; border-width: 1px; /* box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.4) inset, 0 2px 6px rgba(0, 0, 0, 0.5), 0 -4px 8px -1px rgba(255, 255, 255, 0.4) inset; */ } .glass2:before { position: absolute; content: ""; top: -2px; left: 2%; width: 96%; height: 2px; background: linear-gradient( to right, rgba(0,0,0,0) 0%, rgba(0,0,0,0.75) 15%, rgba(0,0,0,0.9) 50%, rgba(0,0,0,0.75) 85%, rgba(0,0,0,0) 100% ); z-index: 1; } .glass2:after { position: absolute; content: ""; top: 100%; left: 2%; width: 96%; height: 2px; background: linear-gradient( to right, rgba(0,0,0,0) 0%, rgba(0,0,0,0.5) 5%, rgba(0,0,0,0.9) 50%, rgba(0,0,0,0.5) 95%, rgba(0,0,0,0) 100% ); z-index: 1; } .glass3 { transition: all 0.1s ease-in-out; border-color: rgba(255, 255, 255, 0.6); border-image: none; border-style: double; border-width: 1px; } .glass3ref { position: relative; top: -73px; width: 200px; height: 45px; border-radius: 6px; background: linear-gradient( 172deg, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0.4) 20%, rgba(255,255,255,0.1) 48%, rgba(255,255,255,0.0) 49%, rgba(255,255,255,0.0) 100% ); z-index: 1; } .glass3:before { position: absolute; content: ""; top: -2px; left: 2%; width: 96%; height: 2px; background: linear-gradient( to right, rgba(0,0,0,0) 0%, rgba(0,0,0,0.75) 15%, rgba(0,0,0,0.9) 50%, rgba(0,0,0,0.75) 85%, rgba(0,0,0,0) 100% ); z-index: 1; } .glass3:after { position: absolute; content: ""; top: 100%; left: 2%; width: 96%; height: 2px; background: linear-gradient( to right, rgba(0,0,0,0) 0%, rgba(0,0,0,0.5) 5%, rgba(0,0,0,0.9) 50%, rgba(0,0,0,0.5) 95%, rgba(0,0,0,0) 100% ); z-index: 1; } div.glass3hi:before { position: absolute; content: ""; top: -2px; left: 10%; width: 36px; height: 3px; background: linear-gradient( to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.99) 50%, rgba(255,255,255,0) 100% ); z-index: 1; } div.glass3hi:after { position: absolute; content: ""; top: -2px; left: calc(10% + 16px); width: 4px; height: 2px; background-color: #fff; box-shadow: 0 0 8px 3px rgba(255,255,255,0.99); z-index: 1; } #hi2 { transform: translate(120px, -10px); z-index: 9; } #hi3 { transform: rotate(90deg) translate(-35px, -100px); z-index: 9; } button:hover.clear-a { color: rgba(255, 255, 255, 0.99); text-shadow: 0px 0px 2px rgba(255, 255, 255, 0.99), 0px 0px 4px rgba(255, 255, 255, 0.75); border-color: rgba(255, 255, 255, 0.4); box-shadow: 0 1px 0 0 rgba(255, 255, 255, 0.4) inset, 0 2px 6px rgba(0, 0, 0, 0.5), 0 10px rgba(0, 0, 0, 0.05) inset, 0 0 5px 2px rgba(255, 255, 255, 0.75), 0 0 10px 2px rgba(255, 255, 255, 0.75) inset; } .glass3hover { position: relative; top: -30px; left: -1px; width: 198px; height: 41px; line-height: 36px; border-radius: 6px; color: #000; background: radial-gradient( ellipse at center, rgba(255,255,255,1) 0%, rgba(255,255,255,0) 100% ); /* W3C */ opacity: 0.0; transition: all 0.3s ease-in-out; z-index: 2; box-shadow: 0 0 6px 3px rgba(255,255,255,0.5); border: 2px groove rgba(255,255,255,0.5); } div:hover.glass3hover { opacity: 1.0; } |
2#: HTML код кнопочек выглядит следующим образом:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<div class="content"> <div class="centered"> <div class="vert"> <button class="button glass clear-a" type="button">Original</button><br/> <button class="button glass2" type="button">New</button><br/> <div class="button glass3 clear">New Shiny <div class="glass3hover">New Shiny</div> <div class="glass3ref"></div> <div class="glass3hi"></div> <div id="hi3" class="glass3hi"></div> </div> </div> </div> |
Остались вопросы? Вы всегда можете задать их в комментариях
А для чего в коде два блока <div id="hi3" class="glass3hi"></div>?
Опечатка в коде. Спасибо за бдительность!