So with the possibilities of HTML marquee, I came super close to what I want to create.
.marquee {
background-color: antiquewhite;
width: 150px;
margin: 0 auto;
overflow: hidden;
white-space: nowrap;
display: inline-block;
vertical-align: middle;
}
.marquee span {
font-size: 40px;
position: relative;
left: 100%;
animation: marquee 2s linear infinite;
}
.marquee:hover span {
animation-play-state: paused;
}
.marquee span:nth-child(1) {
animation-delay: 0s;
}
.marquee span:nth-child(2) {
animation-delay: 0.8s;
}
.marquee span:nth-child(3) {
animation-delay: 1.6s;
}
.marquee span:nth-child(4) {
animation-delay: 2.4s;
}
.marquee span:nth-child(5) {
animation-delay: 3.2s;
}
#keyframes marquee {
0% {left: 100%;}
100% {left: -100%;}
}
p{
display: inline;
}
<p class="marquee">
<span>this is a</span>
<span>simple marquee</span>
<span>using css</span>
<span>using css</span>
<span>simple marquee</span>
</p>
The only 2 problems:
I don't know how to change the height so that the text will stay in the middle
The words overlap and I can't create a clean loop of the words
UPDATE:
I assume I made it. If anything inside this code is a no-go, please let me know.
If not, this will be a possible CSS only solution for anybody who wants to achieve something similar:
HTML:
<div class="marqueemagic">
<div class="scrollingquee">
</div><div class="scrollingquee" aria-hidden="true">
<i> CONVERSION | OPTIMIZATION |</i>
</div><div class="scrollingquee" aria-hidden="true">
<i>CONVERSION | OPTIMIZATION |</i>
</div><div class="scrollingquee" aria-hidden="true">
<i> CONVERSION | OPTIMIZATION |</i>
</div>
<!-- … -->
</div>
CSS:
.marqueemagic {
overflow: hidden;
white-space: nowrap;
width: 150px;
background-color: white;
display: inline-block;
padding-bottom: 5px;
padding-top: 5px;
margin-bottom: 2px;
font-size: 35px;
vertical-align: bottom;
font-weight: 600;
}
.scrollingquee {
animation: marquee 5s linear infinite;
display: inline-block;
padding-right: 10px;
}
#keyframes marquee {
from {
transform: translateX(0);
}
to {
transform: translateX(-100%);
}
}
Result:
https://youtu.be/Tuy4FUZmVd8
Of course, you can change speed, width, background color, opacity, font related values etc. as you wish without breaking anything.
With kind regards
Chris
Related
I'm a beginner.
To make a thigh, leg and ankle like structure as thick lines. I should rotate it using animation, but they are rotating in the manner such that they are at different points. But I want the joints between the lines should be the same as the knee joint, hip joint.
I have included the code that I tried.
<title> Stick Animation </title>
<style>
body {
font-family: monospace;
align-content: center;
text-align: center;
padding: 20px;
padding-top: 200px;
}
.thigh {
height: 5px;
width: 200px;
position: relative;
background-color: black;
display: inline-block;
transform-origin: right;
animation-name: leg;
animation-duration: 1s;
animation-iteration-count: 10;
animation-direction: alternate-reverse;
}
#keyframes thigh {
from {
transform: rotate(120deg);
}
to {
transform: rotate(100deg);
}
}
.leg {
height: 5px;
width: 170px;
position: relative;
background-color: black;
display: inline-block;
transform-origin: left;
animation-name: leg;
animation-duration: 1s;
animation-iteration-count: 10;
animation-direction: alternate-reverse;
}
#keyframes leg {
from {
transform: rotate(120deg);
}
to {
transform: rotate(0deg);
}
}
.ankle {
height: 5px;
width: 50px;
position: relative;
background-color: black;
display: inline-block;
transform-origin: left;
animation-name: ankle;
animation-duration: 1s;
animation-iteration-count: 10;
animation-direction: alternate-reverse;
}
#keyframes ankle {
from {
transform: rotate(60deg);
}
to {
transform: rotate(0deg);
}
}
</style>
<div class="thigh"> </div>
<div class="leg"> </div>
<div class="ankle"> </div>
I want the thigh, leg and ankle should be connected as joints and it should rotate accordingly. This image is my output
You need to set the CSS transform-origin (this is where the transformation takes place). The default in most browsers is center/center which is why things don't stay "connected".
For example
.element {
transform: rotate(45deg);
transform-origin: top left;
}
However, if you want true IK bones, you'll likely need to create something more robust say SVG with animation built in. I'd probably use an animation tool that exports for the web.
I have an h2 header text with the class name "headertekst". I want to center it. I tried to use margin-left: auto, margin-right: auto and width: 100% but nothing happened.
I can give it a margin-left: 20% which will center it but that's just on my laptop. It will not be centered on other screen sizes and on mobile devices.
How do I center it the correct way?
You can just add style in h2 as:
<h2 style="text-align: center;">Text</h2>
h2.headertekst {
text-align: center;
}
<h2 class="headertekst">Test 1</h2>
You can use below css for this
h2 {
width: 100%;
text-align:center;
}
Or
header {
text-align: center;
}
h2 {
display: inline-block;
}
<h2 class="headertekst"> centered text </h2>
.headertekst {
{
text-align: center;
width:100%
}
This is all you need:
.headertekst {
text-align: center;
}
And if you need to center the h2 itself, then just add the text-align: center rule to the parent of the h2 tag.
add style as:
.headertekst{
text-align: center;
}
Here is a workign snippet:
.headertekst{
text-align: center;
}
<h2 class="headertekst">Align this to center</h2>
Ok, the problem is that the last part of your heading is rotating and position absolute. You have to define an approximate average width of the three rotating words.
body {
background: #363636;
}
.headertekst {
color: white;
font-size: 20px;
font-family: "Raleway", Helvetica, Arial, sans-serif;
font-weight: 600;
text-transform: uppercase;
text-align: center;
}
.headertekstrotate {
position: relative;
display: inline-block;
padding: 0 0 0 8px;
width: 150px;
}
.headertekstrotate span {
animation: clock 12s linear infinite 0s;
-ms-animation: clock 12s linear infinite 0s;
-webkit-animation: clock 12s linear infinite 0s;
position: absolute;
left: 0;
top: 0;
opacity: 0;
}
.headertekstrotate span:nth-child(2) {
animation-delay: 4s;
-ms-animation-delay: 4s;
-webkit-animation-delay: 4s;
}
.headertekstrotate span:nth-child(3) {
animation-delay: 8s;
-ms-animation-delay: 8s;
-webkit-animation-delay: 8s;
}
#keyframes clock {
0% {
opacity: 0;
}
10% {
opacity: 1;
}
25% {
opacity: 1;
}
30% {
opacity: 0;
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
<h2 class="headertekst">Interlaser is
<div class="headertekstrotate">
<span>professioneel.</span>
<span>voordelig.</span>
<span>betrouwbaar.</span>
</div>
</h2>
Other way:
body {
background: #363636;
}
.headertekst {
color: white;
font-size: 20px;
font-family: "Raleway", Helvetica, Arial, sans-serif;
font-weight: 600;
text-transform: uppercase;
text-align: center;
}
.headertekstrotate {
position: relative;
}
.headertekstrotate span {
animation: clock 12s linear infinite 0s;
-ms-animation: clock 12s linear infinite 0s;
-webkit-animation: clock 12s linear infinite 0s;
position: absolute;
left: 0;
top: 0;
width: 100%;
opacity: 0;
}
.headertekstrotate span:nth-child(2) {
animation-delay: 4s;
-ms-animation-delay: 4s;
-webkit-animation-delay: 4s;
}
.headertekstrotate span:nth-child(3) {
animation-delay: 8s;
-ms-animation-delay: 8s;
-webkit-animation-delay: 8s;
}
#keyframes clock {
0% {
opacity: 0;
}
10% {
opacity: 1;
}
25% {
opacity: 1;
}
30% {
opacity: 0;
}
80% {
opacity: 0;
}
100% {
opacity: 0;
}
}
<h2 class="headertekst">
<div class="headertekstrotate">
<span>Interlaser is short.</span>
<span>Interlaser is very very long.</span>
<span>Interlaser is professioneel.</span>
</div>
</h2>
Try to something like this.
.headertekst{
left: 0;
right: 0;
width: 100%;
text-align: center;
}
<h2 class="headertekst">This is Heading</h2>
try this
.headertekst
{
text-align:center;
width:100%;
}
.headertekst
{
text-align:center;
width:100%;
}
<h2 class="headertekst">This is center text</h2>
Simply change the Css properties to this:
.headertekst {
width: 100%
display: inline-block;
overflow: hidden;
text-align: center;
}
Reason: Sometimes text-align does not works if there is no width set. And overflow should always be kept hidden in these cases. display: inline-block As its name says: it displays the element in a line in a block. And finally, text-align: center it aligns the text to center.
I'm trying to animate a scrolling text (in a paragraph) so that it will move from the bottom to the top of a div, scroll out of the div (become invisible) and then loop. Here is the relevant css:
#keyframes showAndScroll {
0% {opacity: 0;}
10% {opacity: 0.85;}
50% {opacity: 0.85;}
60% {opacity: 0;}
100% {opacity: 0;}
}
.infobar {
position: absolute;
width: 100%;
height: 30%;
bottom: 0%;
color: white;
background-color: red;
opacity: 0.75;
text-indent: 30px;
font-size: 200%;
pointer-events: none;
animation-name: showAndScroll;
animation-duration: 40s;
animation-iteration-count: infinite;
}
#keyframes scroll {
0% {
transform: translateY(600%); color: red;
}
50% {
transform: translateY(-200%); color: blue;
}
}
.infobar p {
position: absolute;
width: 100%;
overflow: hidden;
display: inline-block;
animation-name: scroll;
animation-duration: 40s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
And the html code:
<div class="infobar">
<p>
Infobar test
<p>
</div>
I'm having two issues:
The text overlaps the rest of the document. How can I make the paragraph invisible as it hits the edge of its parent div? This effect is what I'm looking for: http://media02.hongkiat.com/marquee-css3-animation//demo/index2.html
For some reason, placing the paragraph at 100% of the div doesn't seem to put it on the "bottom" of the div (I've currently placed it at 600%). Why is this?
Any input is appreciated. Here is my JSfiddle: https://jsfiddle.net/essi/oqh6ok00/1/
Add overflow: hidden; to class .infobar. In this way the overflow is clipped, and your animated element will be visible within edges similarly to what you have shown us in your link example.
#keyframes showAndScroll {
0% {
opacity: 0;
}
10% {
opacity: 0.85;
}
50% {
opacity: 0.85;
}
60% {
opacity: 0;
}
100% {
opacity: 0;
}
}
.infobar {
position: absolute;
width: 100%;
height: 30%;
bottom: 0%;
color: white;
background-color: red;
opacity: 0.75;
text-indent: 30px;
font-size: 200%;
pointer-events: none;
animation-name: showAndScroll;
animation-duration: 40s;
animation-iteration-count: infinite;
overflow: hidden;
}
#keyframes scroll {
0% {
transform: translateY(600%);
color: red;
}
50% {
transform: translateY(-200%);
color: blue;
}
}
.infobar p {
position: absolute;
width: 100%;
overflow: hidden;
display: inline-block;
animation-name: scroll;
animation-duration: 40s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
<div class="infobar">
<p>
Infobar test
<p>
</div>
I have some misbehaving text in a CSS animation.
The text appears to "type" itself out, and then end with a blinking cursor. It does this well, but when it's done typing a line that line tends to "float" or "shift" itself over to the center of the page.
I am centering the text with text-align: center; as well as with a flexbox (to get it center of the page).
Here's a link to a JSFiddle
And here's some code:
html, body {
height: 100%;
width: 100%;
}
body {
overflow-x: hidden;
overflow-y: hidden;
}
.do-you-even-flexbox, .content {
position:relative;
top:0;
width:100%;
height:100%;
}
.content {
padding:8px 20px 15px;
display:flex;
align-content:center;
}
.box {
height:20%;
margin:auto
}
h1 {
text-align: center;
font-size: 75px;
margin-top: 0em;
margin-bottom: 0em;
padding: 0em;
}
h2 {
font-size: 50px;
text-align: center;
margin-top: 0em;
margin-bottom: 0em;
padding: 0em;
}
h3 {
font-size: 25px;
text-align: center;
margin-top: 0em;
margin-bottom: 0em;
padding: 0em;
}
a {
color: #000;
text-decoration: none;
}
.content h1 {
white-space:nowrap;
overflow:hidden;
-webkit-animation: typing 5s steps(60, end);
-moz-animation: typing 5s steps(60, end);
}
.content h2 {
white-space:nowrap;
overflow:hidden;
-webkit-animation: typing 5s steps(60, end);
-webkit-animation-delay: 4s;
-webkit-animation-fill-mode:both;
-moz-animation: typing 5s steps(60, end);
-moz-animation-delay:4s;
-moz-animation-fill-mode:both;
}
.content h3 {
white-space: nowrap;
overflow: hidden;
-webkit-animation: typing 10s steps(120, end);
-webkit-animation-delay: 8s;
-webkit-animation-fill-mode: both;
-moz-animation: typing 10s steps(120, end);
-moz-animation-delay: 8s;
-moz-animation-fill-mode: both;
}
span {
-webkit-animation: blink 1s infinite;
-moz-animation: blink 1s infinite;
}
#-webkit-keyframes typing {
from { width: 0; }
to { width: 100%; }
}
#-webkit-keyframes blink {
to { opacity: .0;}
}
#-moz-keyframes typing {
from { width: 0; }
to { width: 100%; }
}
#-moz-keyframes blink {
to { opacity: .0; }
}
And here's some HTML that goes with it:
<i class="do-you-even-flexbox"></i>
<div class="content">
<div class="box">
<h1>This wasn't the same as the fiddle code.</p>
<h2>So I've removed some details so it's similar to the fiddle.</p>
<h3>~ get in touch ~ about me ~ blog ~ projects ~ my portfolio ~<span> |</span></h3>
</div>
</div>
well, the problem seems to be with the animation from 0 to 100%, since Heading tags are blocks, and blocks always are 100% percent from its container, the animation actually goes from 0 to the total width of the page. What you are trying to do here its a little bit tricky but can be done nesting a tag inside every Heading tag and animating that tag while giving each heading tag inline behavior which ensures the width is not 100% of the container but just the text.
html, body {
height: 100%;
width: 100%;
}
body {
overflow-x: hidden;
overflow-y: hidden;
}
.do-you-even-flexbox, .content {
position:relative;
top:0;
width:100%;
height:100%;
}
.content {
padding:8px 20px 15px;
display:flex;
align-content:center;
}
.box {
height:20%;
margin:auto
text-align: center;
}
h1, h2, h3 {
display: inline-block;
position: relative;
background-color: #cccccc;
}
h1 span {
font-size: 75px;
margin: 0;
padding: 0em;
display: block;
background-color: #ff0000;
}
h2 span {
font-size: 50px;
text-align: center;
margin-top: 0em;
margin-bottom: 0em;
padding: 0em;
}
h3 span {
font-size: 25px;
text-align: center;
margin-top: 0em;
margin-bottom: 0em;
padding: 0em;
}
a {
color: #000;
text-decoration: none;
}
.content h1 span {
white-space:nowrap;
overflow:hidden;
-webkit-animation: typing 2s steps(60, end);
-moz-animation: typing 2s steps(60, end);
}
.content h2 {
white-space:nowrap;
overflow:hidden;
-webkit-animation: typing 2s steps(60, end);
-webkit-animation-delay: 2s;
-webkit-animation-fill-mode:both;
-moz-animation: typing 2s steps(60, end);
-moz-animation-delay:2s;
-moz-animation-fill-mode:both;
}
.content h3 {
white-space: nowrap;
overflow: hidden;
-webkit-animation: typing 10s steps(120, end);
-webkit-animation-delay: 2s;
-webkit-animation-fill-mode: both;
-moz-animation: typing 2s steps(120, end);
-moz-animation-delay: 2s;
-moz-animation-fill-mode: both;
}
span.caret {
-webkit-animation: blink 1s infinite;
-moz-animation: blink 1s infinite;
}
#-webkit-keyframes typing {
from { width: 0; }
to { width: 100%; }
}
#-webkit-keyframes blink {
to { opacity: .0;}
}
#-moz-keyframes typing {
from { width: 0; }
to { width: 100%; }
}
#-moz-keyframes blink {
to { opacity: .0; }
}
<i class="do-you-even-flexbox"></i>
<div class="content">
<div class="box">
<h1><span>This</span></h1>
<br>
<h2><span>This is a subtitile</span></h2>
<br>
<h3><span>These are links to things on other pages.<span class="caret">|</span> </span></h3>
</div>
</div>
I have a 'bouncing loader' div, in which moves up and down on an infinite loop (see this jsfiddle
However, if I place a button below it, (or anything else for that matter), it will also move in time to the animation effect.
Is there anyway of stopping this button from moving?
I have tried adding margins/padding on both, but they didn't work so I removed them.
the loader html:
<div class="loader" style="float:initial;">
<span></span>
<span></span>
<span></span>
</div>
<br />
<div>
<button id="popupArea">Click here to invoke a popup window</button>
</div>
with the css being:
.loader {
text-align: center;
}
.loader span {
display: inline-block;
vertical-align: middle;
width: 10px;
height: 10px;
margin: 50px auto;
background: black;
border-radius: 50px;
-webkit-animation: loader 0.9s infinite alternate;
-moz-animation: loader 0.9s infinite alternate;
}
.loader span:nth-of-type(2) {
-webkit-animation-delay: 0.3s;
-moz-animation-delay: 0.3s;
}
.loader span:nth-of-type(3) {
-webkit-animation-delay: 0.6s;
-moz-animation-delay: 0.6s;
}
#-webkit-keyframes loader {
0% {
width: 10px;
height: 10px;
opacity: 0.9;
-webkit-transform: translateY(0);
}
100% {
width: 24px;
height: 24px;
opacity: 0.1;
-webkit-transform: translateY(-21px);
}
}
#-moz-keyframes loader {
0% {
width: 10px;
height: 10px;
opacity: 0.9;
-moz-transform: translateY(0);
}
100% {
width: 24px;
height: 24px;
opacity: 0.1;
-moz-transform: translateY(-21px);
}
}
As always, any help/advice is welcomed.
Please note, I'm don't know jquery, so would like to avoid it as much as possible (hence i'm using asp MVC)
Just add the following css attribute:
#popupArea {
position:fixed;
top:100px;//you can change the value as you wish
}
Example here.
try like this
.loader {
text-align: center;
}
.loader span {
display: inline-block;
vertical-align: middle;
width: 10px;
height: 10px;
margin: 50px auto;
background: black;
border-radius: 50px;
-webkit-animation: loader 0.9s infinite alternate;
-moz-animation: loader 0.9s infinite alternate;
}
.loader span:nth-of-type(2) {
-webkit-animation-delay: 0.3s;
-moz-animation-delay: 0.3s;
}
.loader span:nth-of-type(3) {
-webkit-animation-delay: 0.6s;
-moz-animation-delay: 0.6s;
}
#-webkit-keyframes loader {
0% {
width: 10px;
height: 10px;
opacity: 0.9;
-webkit-transform: translateY(0);
}
100% {
width: 24px;
height: 24px;
opacity: 0.1;
-webkit-transform: translateY(-21px);
}
}
#-moz-keyframes loader {
0% {
width: 10px;
height: 10px;
opacity: 0.9;
-moz-transform: translateY(0);
}
100% {
width: 24px;
height: 24px;
opacity: 0.1;
-moz-transform: translateY(-21px);
}
}
<div class="loader" style="height:100px;">
<span></span>
<span></span>
<span></span>
</div>
<br />
<div>
<button id="popupArea">Click here to invoke a popup window</button>
</div>
Try to put height at loader's div .
.loader {
text-align: center;
height:85px;
}
http://jsfiddle.net/csdtesting/9emc9so9/4/
Simple, just set the height for the span
Set height: 100px; in the loader
.loader {
text-align: center;
height:100px;
}
Here is a DEMO