Несколько необычных и стильных эффектов для ссылок, с использованием псевдо-элементов и SVGs.
Изображение
Сложность для применения различных эффектов, при наведении на ссылки, заключается в том, что они окружены текстом. Поэтому применяя те или иные стили, нужно позаботиться чтобы не поломало окружающий текст.
Для этого мы используем псевдо-элементы ::before и ::after.
Тут следует учесть, что не все браузеры поддерживают переходы (transitions) для псевдо-элементов. Поэтому некоторые из примеров, в некоторых браузерах, могут немного мерцать. Например. в том же IE.

Пример работы можно посмотреть под спойлером.
+Пример

Теперь, как можно реализовать такие ссылки на своём форуме.

Общие стили для всех примеров:

Код: Выделить всё

.content a {
position: relative;
display: inline-block;
outline: none;
color: #404d5b;
vertical-align: bottom;
text-decoration: none !important;
border: 0;
background: none !important;
white-space: nowrap;
}

.content a::before,
.content a::after {
pointer-events: none;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-font-smoothing: antialiased;
font-smoothing: antialiased;
}
Пример 1 - Fade in background

Код: Выделить всё

/* Fade in background */
.content a {
border-bottom: 1px solid rgba(52,73,94,0.4);
font-weight: 500;
-webkit-transition: background-color 0.3s, border-color 0.3s;
transition: background-color 0.3s, border-color 0.3s;
}

.content a:hover,
.content a:focus {
border-color: rgba(52,73,94,0);
background-color: rgba(52,73,94,0.1);
}
Пример 2 - Slide up

Код: Выделить всё

/* Slide up */
.content a {
overflow: hidden;
font-weight: 500;
}

.content a::before {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(52,73,94,0.2);
content: '';
-webkit-transition: -webkit-transform 0.2s;
transition: transform 0.2s;
-webkit-transform: translateY(95%);
transform: translateY(95%);
}

.content a:hover::before,
.content a:focus::before {
-webkit-transform: translateY(0);
transform: translateY(0);
}
Пример 3 - Slide right

Код: Выделить всё

/* Slide right */
.content a {
overflow: hidden;
font-weight: 500;
z-index: 1;
}

.content a::before {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(149,165,166,0.4);
content: '';
-webkit-transition: -webkit-transform 0.3s;
transition: transform 0.3s;
-webkit-transform: scaleY(0.618) translateX(-100%);
transform: scaleY(0.618) translateX(-100%);
}

.content a:hover::before,
.content a:focus::before {
-webkit-transform: scaleY(0.618) translateX(0);
transform: scaleY(0.618) translateX(0);
}
Пример 4 - Scale up

Код: Выделить всё

/* Scale up */
.content a {
color: #e74c3c;
font-weight: 500;
z-index: 1;
}

.content a::before {
position: absolute;
top: 0;
left: -5px;
z-index: -1;
box-sizing: content-box;
padding: 0 5px;
width: 100%;
height: 100%;
border-radius: 10px;
background-color: #fff;
content: '';
opacity: 0;
-webkit-transition: -webkit-transform 0.2s, opacity 0.2s;
transition: transform 0.2s, opacity 0.2s;
-webkit-transform: scale(0);
transform: scale(0);
}

.content a:hover::before,
.content a:focus::before {
opacity: 1;
-webkit-transform: scale(1);
transform: scale(1);
}
Пример 5 - Scale up bounce

Код: Выделить всё

/* Scale up bounce */
.content a {
vertical-align: bottom;
font-weight: 500;
z-index: 1;
}

.content a::before {
position: absolute;
top: 0;
left: -5px;
z-index: -1;
box-sizing: content-box;
padding: 0 5px;
width: 100%;
height: 100%;
background-color: #fff;
content: '';
opacity: 0;
-webkit-transition: -webkit-transform 0.2s, opacity 0.2s;
transition: transform 0.2s, opacity 0.2s;
-webkit-transition-timing-function: cubic-bezier(0.25,0.25,0.325,1.39);
transition-timing-function: cubic-bezier(0.25,0.25,0.325,1.39);
-webkit-transform: scale(0);
transform: scale(0);
}

.content a:hover::before,
.content a:focus::before {
opacity: 1;
-webkit-transform: scale(1);
transform: scale(1);
}
Пример 6 - Scale down

Код: Выделить всё

/* Scale down */
.content a {
color: #293b4c;
font-weight: 500;
-webkit-transition: color 0.3s;
transition: color 0.3s;
z-index: 1;
}

.content a:hover,
.content a:focus {
color: #f3f3f3;
}

.content a::before {
position: absolute;
top: 0;
left: 0;
z-index: -1;
width: 100%;
height: 100%;
border-radius: 5px;
background-color: rgba(255,255,255,1);
content: '';
opacity: 0;
-webkit-transition: -webkit-transform 0.2s, opacity 0.3s, background-color 0.2s;
transition: transform 0.2s, opacity 0.2s, background-color 0.2s;
-webkit-transform: scale(1.1);
transform: scale(1.1);
}

.content a:hover::before,
.content a:focus::before {
background-color: rgba(255,255,255,0);
opacity: 1;
-webkit-transform: scaleX(1) scaleY(0.618);
transform: scaleX(1) scaleY(0.618);
}
Пример 7 - Flip

Код: Выделить всё

/* Flip */
.content a {
font-weight: 500;
-webkit-transition: color 0.3s;
transition: color 0.3s;
-webkit-perspective: 600px;
perspective: 600px;
-webkit-perspective-origin: 50% 100%;
perspective-origin: 50% 100%;
}

.content a:hover,
.content a:focus {
color: #e74c3c;
}

.content a::before,
.content a::after {
position: absolute;
top: 0;
left: -4px;
z-index: -1;
box-sizing: content-box;
padding: 0 4px;
width: 100%;
height: 100%;
content: '';
}

.content a::before {
background-color: #fff;
-webkit-transition: -webkit-transform 0.2s;
transition: transform 0.2s;
-webkit-transition-timing-function: cubic-bezier(0.7,0,0.3,1);
transition-timing-function: cubic-bezier(0.7,0,0.3,1);
-webkit-transform: rotateX(90deg);
transform: rotateX(90deg);
-webkit-transform-origin: 50% 100%;
transform-origin: 50% 100%;
}

.content a:hover::before,
.content a:focus::before {
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
}

.content a::after {
border-bottom: 2px solid #fff;
}
Пример 8 - Border

Код: Выделить всё

/* Border */
.content a {
color: #e74c3c;
font-weight: 500;
-webkit-transition: -webkit-transform 0.2s;
transition: transform 0.2s;
}

.content a:hover,
.content a:focus {
-webkit-transform: scale(0.8333);
transform: scale(0.8333);
}

.content a::before {
position: absolute;
top: -2px;
left: -7px;
box-sizing: content-box;
padding: 0 5px;
width: 100%;
height: 100%;
border: 2px solid #e74c3c;
content: '';
opacity: 0;
-webkit-transition: opacity 0.2s, -webkit-transform 0.2s;
transition: opacity 0.2s, transform 0.2s;
-webkit-transform: scale(0.8333);
transform: scale(0.8333);
}

.content a:hover::before,
.content a:focus::before {
opacity: 1;
-webkit-transform: scale(1.2);
transform: scale(1.2);
}
Пример 9 - Skewed

Код: Выделить всё

/* Skewed */
.content a {
font-weight: 500;
-webkit-transition: color 0.2s;
transition: color 0.2s;
z-index: 1;
}

.content a:hover,
.content a:focus {
color: #fff;
}

.content a::before {
position: absolute;
top: 0px;
left: -5px;
z-index: -1;
box-sizing: content-box;
padding: 0 5px;
width: 100%;
height: 100%;
background: #e74c3c;
content: '';
opacity: 0;
-webkit-transition: -webkit-transform 0.2s, opacity 0.2s;
transition: transform 0.2s, opacity 0.2s;
-webkit-transform: skewY(-3deg) skewX(-11deg);
transform: skewY(-3deg) skewX(-11deg);
}

.content a:hover::before,
.content a:focus::before {
opacity: 1;
-webkit-transform: skewY(0) skewX(0);
transform: skewY(0) skewX(0);
}
Пример 10 - Text up line

Код: Выделить всё

/* Text up line */
.content a {
overflow: hidden;
font-weight: 800;
-webkit-transition: -webkit-transform 0.3s;
transition: transform 0.3s;
}

.content a:hover,
.content a:focus {
-webkit-transform: translateY(10%);
transform: translateY(10%);
}

.content a::before {
position: absolute;
top: 0;
left: 0;
z-index: -1;
width: 100%;
height: 100%;
background: #d1d1d1;
content: '';
-webkit-transition: -webkit-transform 0.3s;
transition: transform 0.3s;
-webkit-transform: translateY(100%) translateY(-5px);
transform: translateY(100%) translateY(-5px);
}

.content a,
.content a::before {
-webkit-transition-timing-function: cubic-bezier(0.6,0,0.4,1);
transition-timing-function: cubic-bezier(0.6,0,0.4,1);
}

.content a:hover::before,
.content a:focus::before {
-webkit-transform: translateY(-100%) translateY(5px);
transform: translateY(-100%) translateY(5px);
}
Пример 11 - Tooltip overlay

Код: Выделить всё

/* Tooltip overlay */
.content a::before {
position: absolute;
top: -50%;
left: -50%;
padding: 0.8em 1em 0em 3.7em;
width: 200%;
height: 200%;
background: #fff url("/images/link.svg") no-repeat -3em 50%;
background-size: auto 40%;
color: #404d5b;
color: transparent;
content: attr(href);
white-space: pre-wrap;
word-break: break-all;
font-weight: 600;
font-size: 80%;
line-height: 1.2;
opacity: 0;
-webkit-transition: opacity 0.3s, color 0.3s, -webkit-transform 0.3s, background-position 0.2s;
transition: opacity 0.3s, color 0.3s, transform 0.3s, background-position 0.2s;
-webkit-transform: scale(0.5);
transform: scale(0.5);
pointer-events: auto;
}

.content a:hover::before,
.content a:focus::before {
background-position: 1em 50%;
color: #404d5b;
opacity: 1;
-webkit-transition-delay: 0s, 0s, 0s, 0.1s;
transition-delay: 0s, 0s, 0s, 0.1s;
-webkit-transform: scale(1) translateY(-75%);
transform: scale(1) translateY(-75%);
}
Пример 12 - Arrow

Код: Выделить всё

/* Arrow */
.content a {
padding: 0 0.25em;
font-weight: 500;
-webkit-transition: -webkit-transform 0.3s;
transition: transform 0.3s;
-webkit-transform: translateX(0);
transform: translateX(0);
}

.content a:hover,
.content a::after {
-webkit-transform: translateX(-1em);
transform: translateX(-1em);
}

.content a::before,
.content a::after {
position: absolute;
height: 100%;
content: '';
}

.content a::before {
left: 0;
z-index: -1;
width: 100%;
background: #fff;
}

.content a::after {
left: 100%;
z-index: -2;
width: 1em;
background: #34495e url("/images/arrow_right.svg") no-repeat 50% 50%;
background-size: 60% auto;
text-align: center;
font-family: Arial, sans-serif;
-webkit-transition: -webkit-transform 0.3s;
transition: transform 0.3s;
pointer-events: auto;
}

.content a:hover::after,
.content a:focus::after {
-webkit-transform: translateX(0);
transform: translateX(0);
}
Пример 13 - Curtain

Код: Выделить всё

/* Curtain */
.content a {
overflow: hidden;
font-weight: 500;
z-index: 1;
}

.content a::before,
.content a::after {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
content: '';
-webkit-transition: -webkit-transform 0.3s;
transition: transform 0.3s;
}

.content a::before {
border-top: 2px solid #fff;
background: transparent;
-webkit-transition-delay: 0.3s;
transition-delay: 0.3s;
-webkit-transform: translateY( calc(100% - 2px) );
transform: translateY( calc(100% - 2px) );
}

.content a:hover::before,
.content a:focus::before {
-webkit-transition-delay: 0s;
transition-delay: 0s;
}

.content a:hover::before,
.content a:focus::before,
.content a:hover::after,
.content a:focus::after {
-webkit-transform: translateX(0);
transform: translateX(0);
}

.content a::after {
z-index: -1;
background: rgba(255,255,255,0.7);
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
}

.content a:hover::after,
.content a:focus::after {
-webkit-transition-delay: 0.3s;
transition-delay: 0.3s;
}
Пример 14 - Text scale

Код: Выделить всё

/* Text scale */
.content a {
padding: 0 0.25em;
font-weight: 500;
-webkit-transition: color 0.2s;
transition: color 0.2s;
}

.content a:hover {
color: #d04c3f;
}

.content a::before,
.content a::after {
position: absolute;
top: 0;
font-weight: 100;
font-size: 120%;
line-height: 1;
opacity: 0;
-webkit-transition: opacity 0.2s, -webkit-transform 0.2s;
transition: opacity 0.2s, transform 0.2s;
}

.content a::before {
left: -0.1em;
content: '[';
-webkit-transform: translateX(-100%);
transform: translateX(-100%);
}

.content a::after {
right: -0.1em;
content: ']';
-webkit-transform: translateX(100%);
transform: translateX(100%);
}

.content a:hover::before,
.content a:hover::after {
opacity: 1;
-webkit-transform: translateX(0);
transform: translateX(0);
}
Пример 15 - Text fall

Код: Выделить всё

/* Text fall */
.content a {
color: #4c8fbb;
font-weight: 400;
-webkit-transition: color 0.3s;
transition: color 0.3s;
-webkit-perspective: 1000px;
perspective: 1000px;
}

.content a:hover {
color: #afd6f0;
}

.content a::before,
.content a::after {
position: absolute;
top: 0;
left: 0;
content: attr(data-dummy);
opacity: 0;
-webkit-transition: -webkit-transform 0.3s, opacity 0.3s, color 0.3s;
transition: transform 0.3s, opacity 0.3s, color 0.3s;
pointer-events: none;
}

.content a::before {
color: #7db8de;
-webkit-transition-delay: 0.15s;
transition-delay: 0.15s;
-webkit-transform: translateY(-100%) translateZ(100px) rotateX(30deg) rotateZ(-10deg);
transform: translateY(-100%) translateZ(100px) rotateX(30deg) rotateZ(-10deg);
}

.content a::after {
color: #afd6f0;
-webkit-transform: translateY(-100%) translateZ(100px) rotateX(-30deg) rotateZ(10deg);
transform: translateY(-100%) translateZ(100px) rotateX(-30deg) rotateZ(10deg);
}

.content a:hover::before,
.content a:hover::after {
color: transparent;
opacity: 1;
-webkit-transform: translateY(0) translateZ(0) rotateX(0) rotateZ(0);
transform: translateY(0) translateZ(0) rotateX(0) rotateZ(0);
}

.content a:hover::before {
-webkit-transition-delay: 0s;
transition-delay: 0s;
}

.content a:hover::after {
-webkit-transition-delay: 0.15s;
transition-delay: 0.15s;
}
Чтобы этот пример работал, помимо стилей в структуру ссылки нужно добавить атрибут data-dummy, ссылка должна выглядеть следующим образом:

Код: Выделить всё

<a href="#" data-dummy="link-adress">link-adress</a>
Пример 16 - SVG line

Код: Выделить всё

/* SVG line */
.content a {
font-weight: 500;
}

.content a svg.link-svgline {
position: absolute;
top: 100%;
left: 0;
overflow: hidden;
margin: 0;
width: 100%;
height: 20px;
-webkit-transition: stroke-dashoffset 0.3s ease-in-out;
transition: stroke-dashoffset 0.3s ease-in-out;
-webkit-transform: translateY(-60%);
transform: translateY(-60%);
fill: none;
stroke: #b1d474;
stroke-width: 2;
stroke-dasharray: 400px;
stroke-dashoffset: 400px;
}

.content a:hover svg.link-svgline {
stroke-dashoffset: 0px;
}
Пример 17 - SVG marker

Код: Выделить всё

/* SVG marker */
.content a {
font-weight: 500;
}

.content a svg.link-svgline {
position: absolute;
top: 100%;
left: 0;
z-index: -1;
overflow: hidden;
margin: 0;
width: 100%;
height: 20px;
opacity: 0.5;
-webkit-transition: stroke-dashoffset 0.3s ease-in-out;
transition: stroke-dashoffset 0.3s ease-in-out;
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
fill: none;
stroke: #f0f567;
stroke-width: 60;
stroke-dasharray: 400px;
stroke-dashoffset: 400px;
}

.content a:hover svg.link-svgline {
stroke-dashoffset: 0px;
}
Чтобы стили SVG line и SVG marker заработали, помимо стилей, необходимо добавить ещё несколько стилей и блок.
Стили для обоих примеров:

Код: Выделить всё

.svg-wrap {
position: absolute;
width: 0px;
height: 0px;
overflow: hidden;
}
Открываете overall_header.html и после <body> добавляете:
Пример 16 - SVG line:

Код: Выделить всё

<div class="svg-wrap">
<svg viewBox="0 0 400 20" xmlns="http://www.w3.org/2000/svg">
<path id="svg_line" d="m 1.986,8.91 c 55.429038,4.081 111.58111,5.822 167.11781,2.867 22.70911,-1.208 45.39828,-0.601 68.126,-0.778 28.38173,-0.223 56.76079,-1.024 85.13721,-1.33 24.17379,-0.261 48.42731,0.571 72.58115,0.571"></path>
</svg>
</div>
Пример 17 - SVG marker:

Код: Выделить всё

<div class="svg-wrap">
<svg viewBox="0 0 400 60" xmlns="http://www.w3.org/2000/svg">
<path id="svg_marker" d="m 3.518915,27.827324 c 55.429038,4.081 111.581115,5.822 167.117815,2.867 22.70911,-1.208 45.39827,-0.601 68.126,-0.778 28.38172,-0.223 56.76078,-1.024 85.13721,-1.33 24.17378,-0.261 48.4273,0.571 72.58114,0.571"></path>
</svg>
</div>
Далее в структуру ссылки нужно добавить, для SVG line:

Код: Выделить всё

<svg class="link-svgline"><use xlink:href="#svg_line"></use></svg>
для SVG marker:

Код: Выделить всё

<svg class="link-svgline"><use xlink:href="#svg_marker"></use></svg>
То есть ссылка должна иметь следующий вид:

Код: Выделить всё

<a href="#">link-adress <svg class="link-svgline"><use xlink:href="#svg_marker"></use></svg></a>
Если у вас нет возможности отредактировать структуру ссылки, можно это реализовать с помощью jquery, если у вас уже подключена её библиотека:

Код: Выделить всё

$(".content a").each(function() {
$(this).append('<svg class="link-svgline"><use xlink:href="#svg_marker"></use></svg>');
});
Добавьте этот скрипт в overall_footer.html перед </body>.

Изображения используемые в 11 и 12 примерах, можно заменить на свои изображения:
Изображение

Изображение


Автор проекта на github.com.
Комментариев нет
Комментариев пока нет, но ты можешь быть первым! Нужно лишь войти или зарегистрироваться и поделиться своим мнением.