Красивые эффекты на кнопках при наведении с использованием CSS3 и SVG
Классные эффекты для кнопочек при наведении курсора мышки. Всё выполнено с использованием CSS3 и SVG
Для начала посмотрите ДЕМО
Установка:
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 |
.buttons * { box-sizing: inherit; -webkit-transition-property: all; transition-property: all; -webkit-transition-duration: .6s; transition-duration: .6s; -webkit-transition-timing-function: ease; transition-timing-function: ease; } .buttons { display: -webkit-box; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; flex-direction: column; height: 100%; -webkit-box-pack: center; justify-content: center; text-align: center; width: 100%; } .buttons .container { -webkit-box-align: center; align-items: center; display: -webkit-box; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; flex-direction: column; -webkit-box-pack: center; justify-content: center; padding: 1em; text-align: center; } @media (min-width: 600px) { .buttons .container { -webkit-box-orient: horizontal; -webkit-box-direction: normal; flex-direction: row; -webkit-box-pack: justify; justify-content: space-between; } } .btn { color: #fff; cursor: pointer; font-size: 16px; font-weight: 400; line-height: 45px; margin: 0 0 2em; max-width: 160px; position: relative; text-decoration: none; text-transform: uppercase; width: 100%; } @media (min-width: 600px) { .btn { margin: 0 1em 2em; } } .btn:hover { text-decoration: none; } .btn-1 { background: #e02c26; font-weight: 100; } .btn-1 svg { height: 45px; left: 0; position: absolute; top: 0; width: 100%; } .btn-1 rect { fill: none; stroke: #fff; stroke-width: 2; stroke-dasharray: 422, 0; -webkit-transition: all 0.35s linear; transition: all 0.35s linear; } .btn-1:hover { background: rgba(225, 51, 45, 0); font-weight: 900; letter-spacing: 1px; } .btn-1:hover rect { stroke-width: 5; stroke-dasharray: 15, 310; stroke-dashoffset: 48; -webkit-transition: all 1.35s cubic-bezier(0.19, 1, 0.22, 1); transition: all 1.35s cubic-bezier(0.19, 1, 0.22, 1); } .btn-2 { letter-spacing: 0; } .btn-2:hover, .btn-2:active { letter-spacing: 5px; } .btn-2:after, .btn-2:before { -webkit-backface-visibility: hidden; backface-visibility: hidden; border: 1px solid rgba(255, 255, 255, 0); bottom: 0px; content: " "; display: block; margin: 0 auto; position: relative; -webkit-transition: all 280ms ease-in-out; transition: all 280ms ease-in-out; width: 0; } .btn-2:hover:after, .btn-2:hover:before { -webkit-backface-visibility: hidden; backface-visibility: hidden; border-color: #fff; -webkit-transition: width 350ms ease-in-out; transition: width 350ms ease-in-out; width: 70%; } .btn-2:hover:before { bottom: auto; top: 0; width: 70%; } .btn-3 { background: #e3403a; border: 1px solid #da251f; box-shadow: 0px 2px 0 #d6251f, 2px 4px 6px #e02a24; font-weight: 900; letter-spacing: 1px; -webkit-transition: all 150ms linear; transition: all 150ms linear; } .btn-3:hover { background: #e02c26; border: 1px solid rgba(0, 0, 0, 0.05); box-shadow: 1px 1px 2px rgba(255, 255, 255, 0.2); color: #ec817d; text-decoration: none; text-shadow: -1px -1px 0 #c2211c; -webkit-transition: all 250ms linear; transition: all 250ms linear; } .btn-4 { border: 1px solid; overflow: hidden; position: relative; } .btn-4 span { z-index: 20; } .btn-4:after { background: #fff; content: ""; height: 155px; left: -75px; opacity: .2; position: absolute; top: -50px; -webkit-transform: rotate(35deg); transform: rotate(35deg); -webkit-transition: all 550ms cubic-bezier(0.19, 1, 0.22, 1); transition: all 550ms cubic-bezier(0.19, 1, 0.22, 1); width: 50px; z-index: -10; } .btn-4:hover:after { left: 120%; -webkit-transition: all 550ms cubic-bezier(0.19, 1, 0.22, 1); transition: all 550ms cubic-bezier(0.19, 1, 0.22, 1); } .btn-5 { border: 0 solid; box-shadow: inset 0 0 20px rgba(255, 255, 255, 0); outline: 1px solid; outline-color: rgba(255, 255, 255, 0.5); outline-offset: 0px; text-shadow: none; -webkit-transition: all 1250ms cubic-bezier(0.19, 1, 0.22, 1); transition: all 1250ms cubic-bezier(0.19, 1, 0.22, 1); } .btn-5:hover { border: 1px solid; box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.5), 0 0 20px rgba(255, 255, 255, 0.2); outline-color: rgba(255, 255, 255, 0); outline-offset: 15px; text-shadow: 1px 1px 2px #427388; } |
2#: Блок с кнопочками вставляем куда-нибудь между <body> и </body>:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<section class="buttons"> <div class="container"> <a href="#" class="btn btn-1"> <svg> <rect x="0" y="0" fill="none" width="100%" height="100%"/> </svg> Hover </a> <!--End of Button 1 --> <a href="#" class="btn btn-2">Hover</a> <!--End of Button 2 --> <a href="#" class="btn btn-3">Hover</a> <!--End of Button 3 --> <a href="#" class="btn btn-4"><span>Hover</span></a> <!--End of Button 4 --> <a href="#" class="btn btn-5">Hover</a> <!--End of Button 5 --> </div> </section> |