Skip to content

Instantly share code, notes, and snippets.

@i2r
Last active November 26, 2019 15:47
Show Gist options
  • Select an option

  • Save i2r/e65b7ff207929bf01c0f5931d9442b5d to your computer and use it in GitHub Desktop.

Select an option

Save i2r/e65b7ff207929bf01c0f5931d9442b5d to your computer and use it in GitHub Desktop.
Smart marquee
/**
* Smart marquee
*/
html, body {
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
}
.marquee {
position: relative;
width: 450px;
margin: 0 auto;
white-space: nowrap;
box-sizing: border-box;
border: solid 1px rgba(255,255,255, 0.5);
}
.marquee span {
display: inline-block;
transition: transform 1s linear;
transform-origin: center;
}
.marquee:hover span {
//transform: translateX(50%);
}
.left,
.right,
.center {
position: absolute;
top: 0;
bottom: 0;
width: 30%;
z-index: 10;
}
.left {
left: 0;
background: rgba(0,255,0, 0.3);
}
.right {
right: 0;
background: rgba(0,255,255, 0.3);
}
.center {
width: auto;
left: 30%;
right: 30%;
background: rgba(255,255,255, 0.3);
}
.left:hover ~ span {
transform: translateX(0);
}
.right:hover ~ span {
transform: translateX(calc(-100% + 450px));
}
.center:hover ~ span {
transform: translateX(calc(-50% + 225px));
}
<p class="marquee">
<i class="left"></i>
<i class="center"></i>
<i class="right"></i>
<span>
Для взрослых и детей! Научим играть на гитаре с нуля за 2 месяца, или вернем деньги!
</span>
</p>
// alert('Hello world!');
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment