Making smoothly animated striped div - html

I'm having trouble making a smoothly animated striped div, like a progress bar.
CSS:
.animationStripes{
width: 300px;
height: 50px;
background-image: repeating-linear-gradient(-45deg, rgb(0, 0, 0), rgb(0, 0, 0) 25px, blue 25px, blue 50px);
-webkit-animation:progress 2s linear infinite;
-moz-animation:progress 2s linear infinite;
-ms-animation:progress 2s linear infinite;
animation:progress 2s linear infinite;
}
#keyframes progress{
0% {
background-position: 0 0;
}
100% {
background-position: -70px 0px;
}
}
http://plnkr.co/edit/4wPv1ogKNMfJ6rQPhZdJ?p=preview
The problem is that there is a weird misalignment on the very right side of the background image gradient. How do i fix this misalignment?

Have you seen this tutorial on CSS Tricks?
#import url(https://fonts.googleapis.com/css?family=Ropa+Sans);
body {
padding: 20px;
font-family: 'Ropa Sans', sans-serif;
}
.product {
width: 376px;
padding: 15px;
position: relative;
float: left;
margin: 0 20px 0 0;
}
.product>img {
display: block;
position: relative;
}
.product:hover .product-hover,
.product:active .product-hover {
opacity: 1;
}
.product-hover {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 0;
transition: opacity 0.3s ease;
background-size: 30px 30px;
background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.1) 25%, transparent 25%, transparent 50%, rgba(0, 0, 0, 0.1) 50%, rgba(0, 0, 0, 0.1) 75%, transparent 75%, transparent);
animation: barberpole 0.5s linear infinite;
}
#keyframes barberpole {
from {
background-position: 0 0;
}
to {
background-position: 60px 30px;
}
}
.product-info {
position: absolute;
bottom: 30px;
right: 30px;
background: white;
width: 150px;
padding: 10px 10px 50px 10px;
}
.subhead {
color: #f00;
text-transform: uppercase;
font-weight: bold;
}
.product-name {
color: #990033;
text-transform: uppercase;
font-weight: bold;
margin: 0;
letter-spacing: -1px;
}
.price {
position: absolute;
bottom: 10px;
right: 10px;
}
.amount {
color: red;
font-size: 150%;
}
.amount>span {
font-size: 75%;
}
h1 {
font-size: 72px;
margin: 2px 0 0 0;
}
VIEW SCSS CODE
<div class="product">
<div class="product-hover"></div> <img src="http://fillmurray.com/300/300" />
<div class="product-info">
<div class="subhead">Sale</div>
<h2 class="product-name">Fleece</h2>
<p class="product-description">Beat the chill and get cozy.</p>
<div class="price"> <span class="from">from</span> <span class="amount"> <span>$</span>9.90 </span>
</div>
</div>
</div>

Well I managed to fix it just by adding one thing and making no alterations to my original code. Simply adding background-size: 150% 100%; kept the image from clipping awkwardly on the right side.
http://plnkr.co/edit/4wPv1ogKNMfJ6rQPhZdJ?p=preview

Make the linear gradient with percentage values, not with pixel. apply background-size, in your case i'd say background-size:50px 50px; and in keyframes, move the background as much, as is the background size background-position: -50px 0px;
Also an example
http://plnkr.co/edit/HrSxkhYZaWp81fAQEaJn?p=preview
If the answer suits you, then mark it as answered and have a good day :)

Related

Glowing border animation with CSS doesn't have a fluid transition

I'm following a tutorial on youtube on how to create a Glowing Border Animation with CSS
I tried to implement it myself and was pretty successful, however, I encountered a problem which I'm unable to solve. When I view my animation there is an uneven transition. It looks like as if two images are stuck together where the colours transition is cut off.
How can I solve the issue there with my transition looks smooth?
I created a JSFiddle to display what I mean:
* {
margin: 0;
padding: 0;
}
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: #151320;
}
.box {
position: relative;
width: 300px;
height: 300px;
color: #fff;
font: 300 2rem 'Montserrat';
text-align: center;
text-transform: uppercase;
display: flex;
align-items: center;
}
.box::before,
.box::after {
content: '';
z-index: -1;
position: absolute;
width: calc(100% + 30px);
height: calc(100% + 30px);
top: -15px;
left: -15px;
background: linear-gradient(45deg, #0096FF, #0047AB, #000000, #6082B6, #87CEEB, #00008B, #145DA0, #00008B, #145DA0, #0096FF, #0047AB, #000000, #6082B6, #87CEEB);
background-repeat: repeat;
border-radius: 5px;
background-size: 600%;
animation: border 12s linear infinite;
}
.box::after {
filter: blur(25px);
}
#keyframes border {
0% {
background-position: 0% 0%;
}
100% {
background-position: 250% 250%;
}
}
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet'>
<div class="box">
Greetings fellow developer!
</div>
Note: The animation looks smooth at first but after about 7ish seconds you encounter the "cut off" where the transition doesn't line up.
Your gradient need to have a kind of repetition to achieve such effect. Make its size 200% 200% then use a repeating gradient where the first color start at 0% and the last one at 50%. Notice how the list of color is repeated twice but in the opposite order.
body {
background: #151320;
}
.box {
position: relative;
width: 300px;
height: 300px;
}
.box::before,
.box::after {
content: '';
z-index: -1;
position: absolute;
inset: -15px;
background:
repeating-linear-gradient(45deg,
#0096FF 0%, #0047AB, #6082B6, #87CEEB, #00008B,
#00008B, #87CEEB, #6082B6,#0047AB,#0096FF 50%);
border-radius: 5px;
background-size: 200% 200%;
animation: border 2s linear infinite;
}
.box::after {
filter: blur(25px);
}
#keyframes border {
0% {
background-position: bottom left;
}
100% {
background-position: top right;
}
}
<div class="box">
</div>

Data-text attribute on an h1 element doesn't show up when adding an animation to the element

I have an h1 element that I want to be invisible and then appear after a few seconds. The element has an ::after pseudo-element that displays a data-text attribute that shadows the h1 element. When I add the animation, I only see the h1 and not the pseudo-element as well. Here is my code
EDIT
adding the animation to the pseudo-element makes it appear, but now the data-text appears over the h1 element when originally it is supposed to go behind it. Here are some pic of what is happening. The first is what it is doing and the second is what I want.
EDIT 2
The problem can be recreated by removing the z-index on the pseudo-element.
<section class="wrapper">
<div class="content-wrapper">
<img class="flipInY" src="./img/neon-blue - flip.png" alt="logo-triangle">
<h1 class="name-ani" data-text="My Name">My Name</h1>
<h2 data-text="web-dev">Web Developer</h2>
</div>
</section>
.wrapper {
.content-wrapper {
z-index: 0;
position: relative;
display: grid;
justify-items: center;
margin-top: 20vh;
img {
width: 350px;
max-width: 100%;
padding: 0 32px;
// transform: rotate(180deg);
filter: brightness(85%);
position: relative;
}
h1 {
background: linear-gradient(
to bottom,
#ebf1f6 0%,
#abd3ee 50%,
#859ee2 51%,
#d5ebfb 100%
);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
font-family: kimberly;
text-transform: uppercase;
font-size: 2.25rem;
transition: font-size 1s;
position: absolute;
top: 10%;
opacity: 0;
&::after {
background: none;
content: attr(data-text);
left: 0;
position: absolute;
text-shadow: 1px -1px 0 rgba(255, 255, 255, 0.5),
3px 1px 3px rgba(255, 0, 255, 0.85),
-3px -2px 3px rgba(0, 0, 255, 0.85),
1px -2px 0 rgba(255, 255, 255, 0.8);
z-index: -10;
opacity: 0;
}
}
.name-ani {
animation-name: name-ani;
animation-duration: 250ms;
animation-delay: 4.5s;
animation-fill-mode: forwards;
}
#keyframes name-ani {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
You need to apply the animation to the pseudo-element as well.
.name-ani,
.name-ani::after {
animation-name: name-ani;
animation-duration: 250ms;
animation-delay: 4.5s;
animation-fill-mode: forwards;
}
Edit: Getting rid of the position: absolute on the h1 by wrapping it and giving it an display: inline solved the stacking order for me as well.
<section class="wrapper">
<div class="content-wrapper">
<img class="flipInY" src="./img/neon-blue - flip.png" alt="logo-triangle">
<div class="h1-wrapper">
<h1 class="name-ani" data-text="My Name">My Name</h1>
</div>
<h2 data-text="web-dev">Web Developer</h2>
</div>
</section>
.wrapper {
.content-wrapper {
z-index: 0;
position: relative;
display: grid;
justify-items: center;
margin-top: 20vh;
img {
width: 350px;
max-width: 100%;
padding: 0 32px;
filter: brightness(85%);
position: relative;
}
.h1-wrapper {
position: absolute;
top: 10%;
}
h1 {
background: linear-gradient(to bottom,
#ebf1f6 0%,
#abd3ee 50%,
#859ee2 51%,
#d5ebfb 100%);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
font-family: kimberly;
text-transform: uppercase;
font-size: 2.25rem;
transition: font-size 1s;
display: inline;
opacity: 0;
&::after {
background: none;
content: attr(data-text);
left: 0;
position: absolute;
text-shadow: 1px -1px 0 rgba(255, 255, 255, 0.5),
3px 1px 3px rgba(255, 0, 255, 0.85),
-3px -2px 3px rgba(0, 0, 255, 0.85),
1px -2px 0 rgba(255, 255, 255, 0.8);
z-index: -10;
opacity: 0;
}
}
.name-ani,
.name-ani::after {
animation-name: name-ani;
animation-duration: 250ms;
animation-delay: 4.5s;
animation-fill-mode: forwards;
}
#keyframes name-ani {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
}
}

CSS Gradient Border Animation Degree Problem

I want to create a gradient border animation starting from the top left to the bottom right. The animation will be used for images within this div.
I tried every degree of angle, but didn't get this to work in the direction I want, it always starts at the right top or at the bottom right.
Also tried it with negative degree values.
.block {
position: relative;
margin: 30px auto 0;
width: 250px;
height: 250px;
background: #272727;
}
.block:before, .block:after {
content: '';
position: absolute;
left: -1px;
top: -1px;
background: linear-gradient(45deg, rgba(0,0,0,0)35%, rgba(0,204,255,1)50%, rgba(0,0,0,0)65%);
background-size: 400%;
width: calc(100% + 2px);
height: calc(100% + 2px);
z-index: -1;
animation: shine 8s linear infinite;
}
#keyframes shine {
to {
background-position: 400% center;
}
}
.block:after {
filter: blur(8px);
}
<div class="block"></div>
Update your code like below:
.block {
position: relative;
margin: 30px auto 0;
width: 250px;
height: 250px;
background: #272727;
}
.block:after {
content: '';
position: absolute;
inset: -1px;
background: linear-gradient(-45deg, rgba(0, 0, 0, 0)35%, rgba(0, 204, 255, 1)50%, rgba(0, 0, 0, 0)65%);
background-size: 400% 400%;
z-index: -1;
animation: shine 3s linear infinite;
filter: blur(8px);
}
#keyframes shine {
from {
background-position: 100% 100%
}
to {
background-position: 0 0
}
}
<div class="block"></div>

Div with Upward Scroll fixed in Centre

Im struggling a bit with this project that I am working on. Essentially I have a chat interface built in angular, im having a problem getting the CSS styling right. At the moment the chat starts at the top, then scrolls down off the screen as the conversation grows. I can scroll with the conversation but this isnt very good UX.
I am trying to make it so the 'Send Message' box starts in the bottom third of the screen and is fixed. Then, as the conversation grows, the messages move upwards/away instead of downwards. Ideally I want this in a container that disappears (behind a header, etc).
I've been trying to wrap my brain around this for the past few days with not much luck. CSS isnt really a strong point of mine. Any help would be greatly appreciated
CSS & Image of current setup below (there is also a separate styling sheet but this is only for the button/message stylings:
<body><style>
body { background: #FFFFFF; color: #727272; }
h1, h2, h3, h4, { background: #FFFFFF; color: #212121; } body { background: #FFFFFF; color: #727272; }
html, body, form, strong, button, small, input, p, div, h1, h2, h3, h4
{ outline: 0; margin: 0; padding: 0; border: 0; font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; line-height: 1.4em; font-size: 100%; } !important;
a, a:active
{ color: #F8F8F8; text-decoration: none; }
a:hover { text-decoration: underline; }
button,
a { cursor: pointer; } strong { font-weight: 500; }
p, h1, h2, h3, h4 { margin-top: 1em; margin-bottom: 1em; }
h1, h2, h3, h4 { font-weight: 200; font-size: 32px; }
html, body, p, div { font-weight: 200; font-size: 17px; } .clear { clear: both }
.container { padding-right: 7vw; padding-left: 7vw; margin-right: auto; margin-left: auto; height: 100vh; }
</style><style>
/* .header { overflow: hidden; position: relative; min-height: 100vh; padding-bottom: 0vh; text-align: center; color: #F8F8F8; background: linear-gradient( to left, rgba(122,214,184,0.0) 0%, rgba(122,214,184,0.7) 100% ), linear-gradient( to bottom, rgb(60,240,80) 0%, rgb(122,214,184) 100% ); } */
.header { overflow: hidden; position: relative; min-height: 100vh; padding-bottom: 0vh; text-align: center; color: #F8F8F8; background: linear-gradient( to left, rgba(204,52,148,0.0) 0%, rgba(239,45,86,0.7) 100% ), linear-gradient( to bottom, rgb(204,52,148) 0%, rgb(204,52,148) 100% ); }
input::-webkit-input-placeholder { color: rgba(200,255,255,0.5) !important; } .header .signup { margin-top: 4em; } .header
input { background: transparent; color: #F8F8F8; border: 0; border-bottom: 1px solid rgba(255,255,255,0.8); line-height: 2em; font-size: 1.4em; text-align: center; width: 12em; }
/* .angularjs-chat-bubble-white { position: absolute; display: inline-block; background: transparent url(https://i.imgur.com/3Sdc2xD.png); background-size: 100%; background-repeat: no-repeat; } */
.bothello-bubble { position: absolute; display: inline-block; background: transparent url(https://i.imgur.com/kN9kf2o.png); background-size: 100%; background-repeat: no-repeat; }
.header .bubble-one { top: 15vh; left: 10vw; width: 30px; height: 30px; opacity: 0.1; transform-origin: 70% 400%; animation: bubble-move 3s ease-in-out 0s infinite alternate; }
.header .bubble-two { top: 44vh; left: 6vw; width: 100px; height: 100px; opacity: 0.1; transform-origin: 60% 400%; animation: bubble-move 4s ease-in-out 0s infinite alternate; }
.header .bubble-three { top: 75vh; left: 22vw; width: 20px; height: 20px; opacity: 0.2; transform-origin: 30% 120%; animation: bubble-move 2s ease-in-out 0s infinite alternate; }
.header .bubble-four { top: 14vh; left: 28vw; width: 15px; height: 15px; opacity: 0.1; transform-origin: 20% 400%; animation: bubble-move 2s ease-in-out 0s infinite alternate; }
.header .bubble-five { top: 30vh; left: 66vw; width: 14px; height: 14px; opacity: 0.2; transform-origin: 90% 100%; animation: bubble-move 5s ease-in-out 0s infinite alternate; }
.header .bubble-six { top: 8vh; left: 75vw; width: 23px; height: 23px; opacity: 0.2; transform-origin: 80% 200%; animation: bubble-move 2s ease-in-out 0s infinite alternate; }
.header .bubble-seven { top: 33vh; left: 84vw; width: 120px; height: 120px; opacity: 0.2; transform-origin: 100% 90%; animation: bubble-move 6s ease-in-out 0s infinite alternate; }
.header .bubble-eight { top: 72vh; left: 85vw; width: 360px; height: 360px; opacity: 0.2; transform-origin: -100% 100%; animation: bubble-move 7s ease-in-out 0s infinite alternate; }
/* .messagebox { padding-top: 90vh; position: fixed;} */
#keyframes bubble-move { 0% { opacity: 0.6; transform: scale(1.0) rotate(-8deg) translate(-1px,-2px); } 70% { opacity: 0.3; transform: scale(1.04) rotate(10deg) translate(2px,1px); } 100% { opacity: 0.4;
transform: scale(0.94) rotate(-18deg) translate(-3px,-1px); } }
</style>
<div class="header">
<!-- <div class="container"> -->
<div class="bothello-bubble bubble-one"></div>
<div class="bothello-bubble bubble-two"></div>
<div class="bothello-bubble bubble-three"></div>
<div class="bothello-bubble bubble-four"></div>
<div class="bothello-bubble bubble-five"></div>
<div class="bothello-bubble bubble-six"></div>
<div class="bothello-bubble bubble-seven"></div>
<div class="bothello-bubble bubble-eight"></div>
<div class="container">
<ng-container *ngFor="let message of messages | async">
<div class="message" [ngClass]="{ 'from': message.sentBy === 'bot',
'to': message.sentBy === 'user' }">
{{ message.content }}
</div>
</ng-container>
<div class="messagebox">
<label for="nameField">Your Message</label>
<input [(ngModel)]="formValue" (keyup.enter)="sendMessage()" type="text">
<button (click)="sendMessage()">Send</button>
</div>
<!-- </div> -->
</div>
</div>
</body>
Thanks so much.
Jay
You're looking for:
.container {
display: flex;
flex-direction: column;
}
.container>ng-container {
flex-grow: 1;
overflow: auto;
}
.container>.messagebox {
flex-shrink: 0;
margin-bottom: 3px;
}
You'll also need a small function to scroll <ng-container> to bottom whenever a message gets added to chat, something along these lines:
function scrollToBottom() {
let elem = document.querySelector('ng-container');
elem.scrollTop = elem.scrollHeight;
}
I don't know for sure what are best practices for manipulating DOM nodes in Angular2 (and above) and if there are any favored techniques over .querySelector.
Also note .querySelector can (and should) be used on any DOM node, so you probably want to use it on your ViewContainer rather than on the entire document.
But, since you haven't posted anything related to the JS part, I can't help you more there.

Button not getting positioned

body {
background-image: url("http://www.nozeens.com/wp-content/uploads/2014/11/White-Wallpaper-Pattern-Hd-Background-8-HD-Wallpapers.jpg");
}
.button {
margin-top: 100px;
position: relative;
background: -webkit-linear-gradient(left top, #FF6600, #FFCC00);
/* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
-webkit-transition-duration: 0.4s;
/* Safari */
transition-duration: 4s;
}
#-webkit-keyframes color-change {
0% {
background: -webkit-linear-gradient(left top, #005C66, #008A19);
}
25% {
background: -webkit-linear-gradient(left top, #CC66FF, #990099);
}
50% {
background: -webkit-linear-gradient(left top, #FF8C9E, #FFF2C7);
}
75% {
background: -webkit-linear-gradient(left top, #00A3C7, #00C7B5);
}
100% {
background: -webkit-linear-gradient(left top, #ABFF54, #75FF8A);
}
}
.button2:hover {
height: 250px;
min-width: 200px;
font-size: 75px;
font-family: american captain;
box-shadow: 0 12px 16px 0 rgba(0, 0, 0, 0.24), 0 17px 50px 0 rgba(0, 0, 0, 0.19);
transform: rotate(360deg);
animation: color-change 4s ease infinite;
}
<button class="button button2">Hover Me For Fun</button>
I created this animated button with the animations i just learnt but I can't seem to position it i even tried putting margin-top but it didn't work. At first I thought that it was because of position so I changed it to relative but it is still not working. Any help would be highly appreciated. Thanks :-)