I created a progress bar in CSS, with 4 goals: (0, 1.000, 10.000 and 100.000).
The goal amounts are displayed outside the progress bar, but inside the progress bar I would like to create 2 intervals exactly below the second and the third goal (first goal and last goal are the beginning and the end of the bar).
The interval should be like a line from the top to the bottom of the bar, visible also if the progress bar passes over them (for this I set a transparence on the progress bar's color).
Which is the best way to do it?
.progress-goals {
max-width: 66%;
margin: 0 auto 0;
display: flex;
justify-content: space-between;
}
.progress-goals h3 {
display: inline-block;
}
.progress-goals:last-child {
flex: 1;
}
.progress-bg {
margin: 0px auto 0px;
max-width: 66%;
height: 78px;
border-radius: 5px;
text-align: center;
-moz-box-shadow: inset 0 0 10px #ccc;
-webkit-box-shadow: inset 0 0 10px #ccc;
box-shadow: inset 0 0 10px #ccc;
}
.progress-bar {
height: 78px;
border-radius: 5px;
float: left;
width: 45%;
/* fallback */
background:
rgba(28, 53, 120, 0.7);
}
.progress-bg h4.goal,
.progress-bg h4.raised {
font-family: Arial, sans-serif;
font-size: 2em;
font-weight: 600;
line-height: 78px;
margin: 0;
padding: 0;
text-align: center;
display: inline;
}
.progress-bg h4.raised {
display: inline;
color: #fff;
text-align: center;
}
.progress-bg h4.goal {
color: #b2b2b2;
text-align: center;
}
#keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Firefox */
#-moz-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Safari and Chrome */
#-webkit-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
/* Internet Explorer */
#-ms-keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
body .progress-bg div {
-webkit-animation: progress-bar 2s ease forwards;
-moz-animation: progress-bar 2s ease forwards;
-o-animation: progress-bar 2s ease forwards;
animation: progress-bar 2s ease forwards;
}
#keyframes progress-bar {
from {
width: 0%;
}
to {
width: 45%;
}
}
<div class="progress-goals">
<h3 class="no-goal">$0</h3>
<h3 class="first-goal">$1,000</h3>
<h3 class="second-goal">$10,000</h3>
<h3 class="last-goal">$100,000</h3>
</div>
<div class="progress-bg" id="progress-bg">
<div class="first-goal-bar"></div>
<div class="second-goal-bar"></div>
<div class="progress-bar">
<h4 class="raised">$5,000 raised </h4>
</div>
</div>
Related
I have a typing effect that I like, I want to use it for all my page titles, but the problem is it works by specifying a width. This would be fine for a homepage with a slogan, but if I ever decide to change it all of my width values would need to change too. Is there any way this can still function the same without being based on a width?
The example is what I'm using on my homepage, it's a slogan. But my title's would be single line text like: About, Contact, Support, News, etc.
My code looks like:
<div id="head">
<div class="wrap">
<div>
<p>We Create</p>
<p>Software for</p>
<p>People!!</p>
</div>
</div>
</div>
My CSS looks like:
#head {
background: #000;
height: 700px;
overflow: hidden;
position: relative;
}
#head .wrap {
height: 100%;
margin: 0 auto;
max-width: 850px;
position: relative;
width: 100%;
}
#head .wrap div {
align-items: center;
display: flex;
flex-direction: column;
letter-spacing: 2px;
height: 100%;
position: relative;
width: 100%;
}
#head .wrap div p {
border-right: 5px solid #b5cfd7;
color: #fff;
font-family: 'Montserrat', sans-serif;
font-size: 85px;
font-weight: 900;
margin-left: 10px;
overflow: hidden;
text-transform: uppercase;
white-space: nowrap;
}
#head .wrap div p:nth-child(1) {
animation: type 2s steps(20, end) 0s 1 normal forwards, blink .5s step-end 4s infinite alternate;
width: 575px;
}
#head .wrap div p:nth-child(2) {
animation: type2 2s steps(20, end) 2s 1 normal forwards, blink .5s step-end 4s infinite alternate;
opacity: 0;
width: 775px;
}
#head .wrap div p:nth-child(3) {
animation: type3 2s steps(20, end) 4s 1 normal forwards, blink .5s step-end 4s infinite alternate;
opacity: 0;
width: 475px;
}
/* Animation */
#keyframes type {
0% {
width: 0;
}
99.9% {
border-right: 5px solid #b5cfd7;
}
100% {
border: none;
}
}
/* Animation */
#keyframes type2 {
0% {
width: 0;
}
1% {
opacity: 1;
}
99.9% {
border-right: 5px solid #b5cfd7;
}
100% {
border: none;
opacity: 1;
}
}
/* Animation */
#keyframes type3 {
0% {
width: 0;
}
1% {
opacity: 1;
}
100% {
opacity: 1;
}
}
/* Animation */
#keyframes blink {
50% {
border-color: transparent;
}
}
Live Example: https://codepen.io/joshrodgers/pen/BaxxQzo
Any help is appreciated!
Thanks,
Josh
Ok...
So, I found a solution...it uses some JS, but that's the only way I could get it to work!
Here's how my code looks now:
<div id="head">
<div class="wrap">
<div class="row">
<div class="text">
<p>We create</p>
<p>Software for</p>
<p>People!!</p>
</div>
<div class="title"></div>
</div>
</div>
The CSS:
#head {
background: #000;
overflow: hidden;
position: relative;
}
#head .wrap {
display: flex;
flex: 1;
flex-direction: column;
height: 100%;
margin: 0 auto;
max-width: 850px;
position: relative;
text-align: center;
width: 100%;
}
#head .row {
align-items: center;
display: flex;
height: 100vh;
justify-content: center;
}
#head .text {
display: none;
}
#head .title {
position: relative;
z-index: 1;
}
#head .title span {
color: #fff;
display: block;
font-family: 'Montserrat', sans-serif;
font-size: 85px;
font-weight: 900;
letter-spacing: 2px;
height: 90px;
min-width: 5px;
text-transform: uppercase;
}
#head .cursor:after {
animation: blink 1s linear infinite alternate;
background: #b5cfd7;
content: "";
display: inline-block;
height: 75%;
margin-left: 30px;
opacity: 0;
width: 5px;
}
/* Animation */
#keyframes blink {
0% {
opacity: 0;
}
25% {
opacity: 1;
}
100% {
opacity: 0;
}
}
The JS:
var sentences = [];
var currentText;
$(document).ready(function(){
$('.text p').each(function(){
var text = $(this).text();
text += " ";
sentences.push(text);
});
currentText = sentences.shift();
typeWord(currentText);
});
jQuery.fn.extend({
appendChars: function(char){
$(this).text(char);
}
});
function spliter(string){
return string.trim().split("");
}
function appendTextLine(){
return $('<span class=""></span>').appendTo('.title');
}
function typeWord(text){
if (!text){
return;
}
var charArray = [];
for (i = 0; i < text.length; i++){
var char = text.slice(0,i);
charArray.push(char);
}
var textLine = appendTextLine();
$('.cursor').removeClass('cursor');
textLine.addClass('cursor');
var interval = setInterval(function(){
firstChar = charArray.shift();
$(textLine).appendChars(firstChar);
if (charArray.length === 0){
currentText = sentences.shift();
typeWord(currentText);
clearInterval(interval);
}
},100);
}
I have a pen here: https://codepen.io/joshrodgers/pen/yLjjzYb
Single line text version here: https://codepen.io/joshrodgers/pen/RwyJroQ
There were two problems with my initial code, it wouldn't work with dynamic text, which this solves because it's not based on a width and two the text was not centered in the window, which I didn't realize when I create this post, but the solution also solves that issue as well.
Hope this helps someone!
Thanks,
Josh
I'm trying to make my button fade in with keyframes but it isn't working and I know I'm doing something wrong. I ended up getting the animated text to work but this is giving me a headache and I cannot find info anywhere that has helped me... I'm new to web development so don't be too harsh on me or my (probably ugly and unorganized) code lol. I'm trying to learn as much as I can, so if you can please explain why it isn't working and why something else might? Thanks guys <3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght#300&display=swap" rel="stylesheet">
<title>Welcome! | Video Editing by Scottis</title>
</head>
<body>
<!-- Header -->
<div class="container">
<span class="text1">Video Editing by Scottis</span>
</div>
<!-- Buttons -->
<style>
.btn {
background-color: white;
color: rgb(133, 4, 255);
text-align: center;
font-size: 15px;
font-weight: bold;
margin-right: -250px;
margin-top: 600px;
margin-left: 515px;
padding: 30px;
}
</style>
</head>
<body>
<button class="btn">Portfolio</button>
<button class = "btn">Pricing</button>
<button class="btn">Contact</button>
</body>
</html>
My CSS:
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: sans-serif;
}
body {
margin: 0;
font-family: 'Roboto', sans-serif;
}
body {
background-image: url("./assets/background.png");
background-color: #cccccc;
background-repeat: no-repeat;
}
/* Create three equal columns that floats next to each other */
.col-md-3 {
float: left;
width: 15%;
padding: 15px;
padding: 10px;
margin: auto;
display: block;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media screen and (max-width:768px) {
.col-md-3 {
width: 100% auto;
}
}
.col-md-12 {
text-align: center;
}
.card-title {
text-align: center;
}
.container{
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
}
.container span{
color: white;
text-transform: uppercase;
display: block;
}
.text1{
color: white;
font-size: 60px;
font-weight: 700;
letter-spacing: 8px;
margin-bottom: 20px;
position: relative;
animation: text 3s 1;
}
#keyframes text {
0%{
margin-bottom: -20%;
}
30%{
letter-spacing: 25px;
margin-bottom: -40px;
}
85%{
letter-spacing: 15px;
margin-bottom: -40px;
}
}
}
#keyframes button {
0%{
opacity: 0%;
}
0%{
opacity: 0%;
}
25%{
opacity: 25%;
}
50%{
opacity: 50%;
}
75%{
opacity: 75%;
}
100%{
opacity: 100%;
}
}
You have some issues with your code first off. You are repeating both the head and body tags out of proper valid html sequence. Have a close look at the following page and resource from MDN: https://developer.mozilla.org/en-US/docs/Web/HTML/Element
As to your issue with keyframes, define the class you wish to control with the sequence in your css and add the animation with a unique call name, I used fadeIn. Below I have added Mozilla, webkit, opera and ms #keyframe animations for opacity. I am defining the animation to start the timer (3 seconds) #keyframe 0% { opacity: 0; } , then end at 100% { opacity: 1; }. I add multiple kits for different browsers.
.btn {
animation: fadeIn ease 3s;
-webkit-animation: fadeIn ease 3s;
-moz-animation: fadeIn ease 3s;
-o-animation: fadeIn ease 3s;
-ms-animation: fadeIn ease 3s;
}
#keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-moz-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-webkit-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-o-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: sans-serif;
}
body {
margin: 0;
font-family: 'Roboto', sans-serif;
}
body {
background-image: url("./assets/background.png");
background-color: #cccccc;
background-repeat: no-repeat;
}
/* Start class for buttons animation fadeIn ease */
.btn {
animation: fadeIn ease 3s;
-webkit-animation: fadeIn ease 3s;
-moz-animation: fadeIn ease 3s;
-o-animation: fadeIn ease 3s;
-ms-animation: fadeIn ease 3s;
}
#keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-moz-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-webkit-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-o-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#-ms-keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
/* End of animation keyframes */
/* Create three equal columns that floats next to each other */
.col-md-3 {
float: left;
width: 15%;
padding: 15px;
padding: 10px;
margin: auto;
display: block;
}
/* Clear floats after the columns */
.row:after {
content: "";
display: table;
clear: both;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media screen and (max-width:768px) {
.col-md-3 {
width: 100% auto;
}
}
.col-md-12 {
text-align: center;
}
.card-title {
text-align: center;
}
.container {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
}
.container span {
color: white;
text-transform: uppercase;
display: block;
}
.text1 {
color: white;
font-size: 60px;
font-weight: 700;
letter-spacing: 8px;
margin-bottom: 20px;
position: relative;
animation: text 3s 1;
}
#keyframes text {
0% {
margin-bottom: -20%;
}
30% {
letter-spacing: 25px;
margin-bottom: -40px;
}
85% {
letter-spacing: 15px;
margin-bottom: -40px;
}
}
}
<div class="container">
<span class="text1">Video Editing by Scottis</span>
</div>
<button class="btn">Portfolio</button>
<button class="btn">Pricing</button>
<button class="btn">Contact</button>
I need do the next animation of text:
People dissapears like a flip effect David Walsh Flip Card Effect, and the effect faces every 2 seconds and it will be repeating, contents the text: "Robots", "Animals", "Things" for example, with the flip animation.
Any idea?
One example of flip cards is the next: Stackoverflow How to flip multiple divs using CSS?
#import url('https://fonts.googleapis.com/css?family=Roboto:300');
.divi {
line-height: normal;
color: black;
text-shadow: 0 0 0.2em #87F, 0 0 0.2em #87F, 0 0 0.2em #87F;
}
.div1 { /* For increasing performance ID/Class should've been used. For a small demo it's okaish for now */
animation: showup 7s forwards;
font-family:'Roboto';
font-weight:300;
font-size:28px;
overflow:hidden;
display:inline-block;
white-space:nowrap;
}
.div2 {
font-family: 'Roboto';
font-weight: 300;
font-size: 28px;
overflow: hidden;
width: 0px;
animation: reveal 7s forwards;
animation-iteration-count: 1;
display: inline-block;
white-space: nowrap;
}
.div2 span {
font-family: 'Roboto';
font-weight: 300;
font-size: 28px;
overflow: hidden;
margin-left: -355px;
animation: slidein 7s forwards;
}
#keyframes showup {
0% {
opacity: 0;
}
20% {
opacity: 1;
}
80% {
opacity: 1;
}
100% {
opacity: 1;
}
}
#keyframes slidein {
0% {
margin-left: -800px;
}
20% {
margin-left: -800px;
}
35% {
margin-left: 0px;
}
100% {
margin-left: 0px;
}
}
#keyframes reveal {
0% {
opacity: 0;
width: 0px;
}
20% {
opacity: 1;
width: 0px;
}
30% {
width: auto;
}
80% {
opacity: 1;
}
100% {
opacity: 1;
width: auto;
}
}
<div class="divi" align="center">
<div class="div1">Hello</div>
<div class="div2">
<span>People</span>
</div>
<div class="div3">
<span>Robots</span>
</div>
<div class="div4">
<span>Animals</span>
</div>
<div class="div5">
<span>Things</span>
</div>
</div>
So I took this piece of code: http://codepen.io/thiagoteles/pen/ogoxLw
And I tried to implement it in my blog's title: http://samanx.github.io/
For some reason I can't get it to stay in the center.
I tried creating an additional div and assigning to it this code:
.center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
But no solution: the problem is the:
body {
background-color: black;
}
.main-header {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
height: auto;
min-height: 240px;
height: 60%;
padding: 15% 0;
}
.inner {
position: relative;
width: 80%;
max-width: 710px;
margin: 0 auto;
}
.page-title {
/* margin: 10px 0 10px 0; */
font-size: 2rem;
letter-spacing: -1px;
/* margin: 0 auto; */
white-space: nowrap;
overflow: hidden;
transform: translateY(-50%);
font-weight: 500;
text-align: center;
font-family: "Open Sans", sans-serif;
color: #fff;
}
.page-description {
margin: 0;
font-size: 2rem;
line-height: 1.5em;
font-weight: 400;
font-family: "Merriweather", serif;
letter-spacing: 0.01rem;
color: rgba(255, 255, 255, 0.8);
}
/* Animation */
.anim-typewriter {
animation: typewriter 4s steps(44) 1s 1 normal both blinkTextCursor 500ms steps(44) 0 infinite normal;
-webkit-animation: typewriter 4s steps(44) 1s 1 normal both, blinkTextCursor 500ms steps(44) 0 infinite normal;
-moz-animation: typewriter 4s steps(44) 1s 1 normal both blinkTextCursor 500ms steps(44) 0 infinite normal;
-o-animation: typewriter 4s steps(44) 1s 1 normal both blinkTextCursor 500ms steps(44) 0 infinite normal;
}
#keyframes typewriter {
from {
width: 0;
}
to {
width: 24em;
}
}
#-webkit-keyframes typewriter {
from {
width: 0;
}
to {
width: 24em;
}
}
#-moz-keyframes typewriter {
from {
width: 0;
}
to {
width: 24em;
}
}
#-o-keyframes typewriter {
from {
width: 0;
}
to {
width: 24em;
}
}
#keyframes blinkTextCursor {
from {
border-right-color: rgba(255, 255, 255, .75);
}
to {
border-right-color: transparent;
}
}
#-webkit-keyframes blinkTextCursor {
from {
border-right-color: rgba(255, 255, 255, .75);
}
to {
border-right-color: transparent;
}
}
#-moz-keyframes blinkTextCursor {
from {
border-right-color: rgba(255, 255, 255, .75);
}
to {
border-right-color: transparent;
}
}
#-o-keyframes blinkTextCursor {
from {
border-right-color: rgba(255, 255, 255, .75);
}
to {
border-right-color: transparent;
}
}
<div class="main-header-content inner">
<h1 class="page-title anim-typewriter">TaoJS - All things Javascript</h1>
<h2 class="page-description">All things Javascript: resources, my problems, my solutions</h2>
</div>
My problem is that it moves too much to the right. If I remove the lines:
width: 80%;
max-width: 710px;
Then it's not working on mobile and smaller screens.
What you need here is change some values according to your actual text changing the steps and width.
First some values to the h1:
.page-title {
/*Add this styles to center and keep the fake cursor*/
width:0;
margin:auto;
border-right:1px solid white;
}
Then change the animation to:
.anim-typewriter {
-webkit-animation: typewriter 4s steps(29) 1s 1 normal both, blinkTextCursor 500ms steps(29) 0 infinite normal;
}
#-webkit-keyframes typewriter {
from {
width: 0;
}
to {
width:13em;
}
}
Where 29 steps and 13em width are values relative to the text you want to show.
Check this Snippet:
body {
background-color: black;
}
.main-header {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
height: auto;
min-height: 240px;
height: 60%;
padding: 15% 0;
}
.inner {
position: relative;
width: 80%;
max-width: 710px;
margin: 0 auto;
}
.page-title {
font-size: 2rem;
white-space: nowrap;
overflow: hidden;
font-weight: 500;
text-align: center;
font-family: "Open Sans", sans-serif;
color: #fff;
text-align:center;
width:0;
margin:auto;
border-right:1px solid white;
}
.page-description {
margin: 0;
font-size: 2rem;
line-height: 1.5em;
font-weight: 400;
font-family: "Merriweather", serif;
letter-spacing: 0.01rem;
color: rgba(255, 255, 255, 0.8);
}
/* Animation */
.anim-typewriter {
-webkit-animation: typewriter 4s steps(29) 1s 1 normal both, blinkTextCursor 500ms steps(29) 0 infinite normal;
}
#-webkit-keyframes typewriter {
from {
width: 0;
}
to {
width:13em;
}
}
#-webkit-keyframes blinkTextCursor {
from {
border-right-color: rgba(255, 255, 255, .75);
}
to {
border-right-color: transparent;
}
}
<div class="main-header-content inner">
<h1 class="page-title anim-typewriter">TaoJS - All things Javascript</h1>
<h2 class="page-description">All things Javascript: resources, my problems, my solutions</h2>
</div>
I need to have span with text aligned in the center.
Previously I have used line-height for this purpose, but in this case the text for some items are longer and this doesn't work any more.
JSFiddle: http://jsfiddle.net/4jSdu/
HTML:
<ul>
<li><a><span>Short</span></a>
</li>
<li><a><span>Why Should I Monitor?</span></a>
</li>
</ul>
CSS:
ul {
position: relative;
overflow: hidden;
}
span {
background-color: rgba(216, 25, 11, 0.75);
display: block;
height: 70px;
line-height: 70px;
width: 135px;
color: black;
text-align: center;
/*margin: auto 0;*/
font-weight: bold;
font-size: 15px;
position: absolute;
bottom: 14px;
}
li, a {
width: 135px;
height: 100px;
display: inline-block;
}
EDIT:
I want to note that span element has value bottom: 14px. THere is also animate effect on this span. when page loads span has value bottom: -70px (container has overlfow: hidden,s o this span is not seen) and then it appears (using .animate) and goes to bottom: 14px. So the sollution should consider this.
I cannot get this animate effect working in jsfiddle (http://jsfiddle.net/pr5cL/), but it works on my page that is locally created.
$("ul li:not(.img_active)").mouseenter(function() {
$(this).find("span").css("bottom","-55px");
$(this).find("span").animate({bottom:15},500);
}).mouseleave(function(){
$(this).find("span").animate({bottom:-70},500);
});
Here is link: http://www.sheerdigitaltest.net/janus/
Something like this maybe?
span {
display: inline-block;
line-height:1.25;
vertical-align:middle;
width: 135px;
color: black;
text-align: center;
font-weight: bold;
font-size: 15px;
}
a {
background-color: rgba(216, 25, 11, 0.75);
height: 70px;
line-height: 70px;
font-size:0;
overflow:hidden;
}
li, a {
width: 135px;
display: inline-block;
vertical-align:top;
}
span {
-webkit-animation: slidein 2s ; /* Safari 4+ */
-moz-animation: slidein 2s ; /* Fx 5+ */
-o-animation: slidein 2s ; /* Opera 12+ */
animation: slidein 2s ; /* IE 10+ */
}
#-webkit-keyframes slidein {
0% { margin-top: 70px; }
100% { margin-top: 0; }
}
#-moz-keyframes slidein {
0% { margin-top: 70px; }
100% { margin-top: 0; }
}
#-o-keyframes slidein {
0% { margin-top: 70px; }
100% { margin-top: 0; }
}
#keyframes slidein {
0% { margin-top: 70px; }
100% { margin-top: 0; }
}
Jsfiddle
No IE7 or earlier support. Animation support as per comments.