I'm usually pretty good with getting things responsive but the scrolling text I am using is making it too complicated for me to work out!
I've got some fixed text, then the scrolling text with CSS animation, then another line of fixed text below. I can align them easily in the right place using absolute positioning, but I can't get it to behave responsively and it keeps throwing it out when I resize the screen. Tried adding a text wrapper to all the text to align that but it's not working.
I've had quite a play about with the code but hoping someone can help me :)
Any help really appreciated!
body {
width: 100%;
height: 100%;
/* position: fixed; */
}
.header-wrapper {
background: rgb(251, 186, 10);
background: linear-gradient(40deg, rgba(251, 186, 10, 1) 0%, rgba(255, 212, 0, 1) 50%, rgba(255, 237, 60, 1) 100%);
width: 1440px;
max-width: 100%;
height: 500px;
margin: auto;
/* position: relative; */
}
.all-text-wrap {
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 1440px;
height: 500px;
max-width: 100%;
/* margin: auto; */
}
.content {
position: absolute;
top: 50%;
left: 35%;
transform: translate(-50%, -50%);
height: 200px;
overflow: hidden;
font-family: "Lato", sans-serif;
font-size: 70px;
line-height: 80px;
color: #ecf0f1;
width: 800px;
}
.content__container {
font-weight: 900;
overflow: hidden;
height: 55px;
/* padding: 0 40px; */
}
.content__container__list {
margin-top: 0;
/* padding-left: 110px; */
text-align: left;
list-style: none;
-webkit-animation-name: change;
-webkit-animation-duration: 10s;
-webkit-animation-iteration-count: infinite;
animation-name: change;
animation-duration: 10s;
animation-iteration-count: infinite;
padding: 0;
}
.content__container__list__item {
line-height: 55px;
margin: 0;
}
.intro-headline {
position: absolute;
top: 21%;
left: 35%;
transform: translate(-50%, -50%);
font-weight: 900;
font-size: 70px;
font-family: "Lato", sans-serif;
color: #2f2f2f;
width: 800px;
}
.intro-subline {
position: absolute;
top: 50%;
left: 35%;
transform: translate(-50%, -50%);
font-weight: 900;
font-size: 70px;
font-family: "Lato", sans-serif;
color: #2f2f2f;
width: 800px;
}
@-webkit-keyframes opacity {
0%,
100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
@-webkit-keyframes change {
0%,
7.11%,
100% {
transform: translate3d(0, 0, 0);
}
11.11%,
18.22% {
transform: translate3d(0, -11.11%, 0);
}
22.22%,
29.33% {
transform: translate3d(0, -22.22%, 0);
}
33.33%,
40.44% {
transform: translate3d(0, -33.33%, 0);
}
44.44%,
51.55% {
transform: translate3d(0, -44.44%, 0);
}
55.55%,
62.66% {
transform: translate3d(0, -55.55%, 0);
}
66.66%,
73.77% {
transform: translate3d(0, -66.66%, 0);
}
77.77%,
84.88% {
transform: translate3d(0, -77.77%, 0);
}
88.88%,
95.99% {
transform: translate3d(0, -88.88%, 0);
}
}
@-o-keyframes opacity {
0%,
100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
@-o-keyframes change {
0%,
7.11%,
100% {
transform: translate3d(0, 0, 0);
}
11.11%,
18.22% {
transform: translate3d(0, -11.11%, 0);
}
22.22%,
29.33% {
transform: translate3d(0, -22.22%, 0);
}
33.33%,
40.44% {
transform: translate3d(0, -33.33%, 0);
}
44.44%,
51.55% {
transform: translate3d(0, -44.44%, 0);
}
55.55%,
62.66% {
transform: translate3d(0, -55.55%, 0);
}
66.66%,
73.77% {
transform: translate3d(0, -66.66%, 0);
}
77.77%,
84.88% {
transform: translate3d(0, -77.77%, 0);
}
88.88%,
95.99% {
transform: translate3d(0, -88.88%, 0);
}
}
@-moz-keyframes opacity {
0%,
100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
@-moz-keyframes change {
0%,
7.11%,
100% {
transform: translate3d(0, 0, 0);
}
11.11%,
18.22% {
transform: translate3d(0, -11.11%, 0);
}
22.22%,
29.33% {
transform: translate3d(0, -22.22%, 0);
}
33.33%,
40.44% {
transform: translate3d(0, -33.33%, 0);
}
44.44%,
51.55% {
transform: translate3d(0, -44.44%, 0);
}
55.55%,
62.66% {
transform: translate3d(0, -55.55%, 0);
}
66.66%,
73.77% {
transform: translate3d(0, -66.66%, 0);
}
77.77%,
84.88% {
transform: translate3d(0, -77.77%, 0);
}
88.88%,
95.99% {
transform: translate3d(0, -88.88%, 0);
}
}
@keyframes opacity {
0%,
100% {
opacity: 0;
}
50% {
opacity: 1;
}
}
@keyframes change {
0%,
7.11%,
100% {
transform: translate3d(0, 0, 0);
}
11.11%,
18.22% {
transform: translate3d(0, -11.11%, 0);
}
22.22%,
29.33% {
transform: translate3d(0, -22.22%, 0);
}
33.33%,
40.44% {
transform: translate3d(0, -33.33%, 0);
}
44.44%,
51.55% {
transform: translate3d(0, -44.44%, 0);
}
55.55%,
62.66% {
transform: translate3d(0, -55.55%, 0);
}
66.66%,
73.77% {
transform: translate3d(0, -66.66%, 0);
}
77.77%,
84.88% {
transform: translate3d(0, -77.77%, 0);
}
88.88%,
95.99% {
transform: translate3d(0, -88.88%, 0);
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Scrolling Text</title>
</head>
<body>
<div class="header-wrapper">
<div class="all-text-wrap">
<div class="intro-headline">DO SUMMER</div>
<div class="content">
<div class="content__container">
<ul class="content__container__list">
<li class="content__container__list__item">SUNRISE RUNS</li>
<li class="content__container__list__item">MORNING COFFEES</li>
<li class="content__container__list__item">PARK PICNICS</li>
<li class="content__container__list__item">CITY STROLLS</li>
<li class="content__container__list__item">STREET MARKETS</li>
<li class="content__container__list__item">ARTS FAIRS</li>
<li class="content__container__list__item">MUSIC FESTIVALS</li>
<li class="content__container__list__item">ALFRESCO EVENINGS</li>
<li class="content__container__list__item">URBAN SUNSETS</li>
</ul>
</div>
</div>
<div class="intro-subline">WITH US</div>
</div>
</div>
</body>
</html>