Issue with text filling, CSS Animation - html

This is a CSS and HTML animation, simple text filling.
For some reason the text jumps when there is a space or if I add a dash?
Below you can see the output:
I've added the code below!
.comingsoon-loading {
font-family: 'Poppins', sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.comingsoon-loading h1 {
position: absolute;
font-size: 20vh;
color: #ffcc00;
-webkit-text-stroke: 2px black;
text-transform: uppercase;
}
.comingsoon-loading h1::before {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
color: black;
-webkit-text-stroke: 0px black;
border-right: 4px solid black;
overflow: hidden;
animation: animate 6s linear infinite;
}
/* animation to fill text */
#keyframes animate
{
0%,10%,100%
{
width: 0;
}
50%,70%
{
width: 100%;
}
}
<div class="comingsoon-loading">
<h1 data-text="COMING-SOON">COMING-SOON</h1>
</div>

The problem lies in the way you handle text in your animation.
You are animating a string of text appearing slowly but don't account for any of the inherit string properties such as line breaking.
During your animation, the first word: "COMING", appears normally as the width increases, but once the hyphen appears, HTML thinks you have inserted a word break point and tries to break "SOON" to a new line.
This can be solved by adding white-space: nowrap; to your ::before section, to prevent it from breaking as the animation plays out.
HTML
<div class="comingsoon-loading">
<h1 data-text="COMING-SOON">COMING-SOON</h1>
</div>
CSS
.comingsoon-loading {
font-family: 'Poppins', sans-serif;
margin: 0;
padding: 0;
box-sizing: border-box;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: blue;
}
.comingsoon-loading h1 {
position: absolute;
font-size: 20vh;
color: #ffcc00;
-webkit-text-stroke: 2px black;
text-transform: uppercase;
}
.comingsoon-loading h1::before {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
color: black;
-webkit-text-stroke: 0px black;
border-right: 2px solid black;
overflow: hidden;
animation: animate 5s linear infinite;
white-space: nowrap;
}
/* animation to fill text */
#keyframes animate {
0%,
10%,
100% {
width: 0;
}
50%,
70% {
width: 100%;
}
}

Related

:Focus Not Working for Search bar Input Styling

I have a search bar that displays an outer glow effect with animation when the user hovers over it. the :hover works just fine, but I also want to be able to see this outer glow animation when the user activates or focuses the search bar. The :active also works, but the :focus does not. Please help:
HTML:
<form action="" class="navbar-search">
<div class="navbar-search-input-wrapper" tabindex="0">
<input
type="text"
name='search'
placeholder="Search objects and widgets"
autocomplete="off"
tabindex="0"
onclick="this.focus()"
class="navbar-search-input">
</div>
</form>
CSS:
* {
margin: 0;
padding: 0;
text-decoration: none;
font-family:Verdana, Geneva, Tahoma, sans-serif, FontAwesome;
box-sizing: border-box;
}
.navbar {
display: flex;
gap: 1rem;
align-items: center;
position: sticky;
background-color: #ffffff;
}
.navbar-search {
border: 1px double #000000;
border-radius: 3.125rem;
height: 2.188rem;
width: 18.75rem;
display: flex;
align-items: center;
}
.navbar-search:hover,
.navbar-search:active,
.navbar-search:focus {
border: 1px double #ffffff;
}
.navbar-search-input-wrapper {
position:relative;
border: none;
border-radius: 3.125rem;
width: 100%;
height: 100%;
background-color: #ffffff;
color: #111;
}
.navbar-search-input {
position:relative;
border: none;
border-radius: 3.125rem;
width: 100%;
height: 100%;
background-color: #ffffff;
color: #111;
padding-left: 0.625rem;
}
.navbar-search-input-wrapper:before,
.navbar-search-input-wrapper:active:before,
.navbar-search-input-wrapper:focus-within:before {
content:'';
position: absolute;
background: inherit;
top: -5px;
right: -5px;
bottom: -5px;
left: -5px;
border-radius: 50px;
filter: blur(35px);
opacity: 0;
transition: opacity 0.1s;
}
.navbar-search-input-wrapper:hover:before,
.navbar-search-input-wrapper:active:before,
.navbar-search-input-wrapper:focus-within:before{
opacity: 1;
z-index: -1;
}
.navbar-search-input-wrapper:hover,
.navbar-search-input-wrapper:active,
.navbar-search-input-wrapper:focus {
background-size: 400% !important;
background: linear-gradient(90deg, #03a9f4, #f441a5, #ffeb3b, #03a9f4);
animation: glow 8s linear infinite;
z-index: 1;
}
#keyframes glow {
0%{
background-position: 0%;
}
100%{
background-position: 400%;
}
}

How to align name and messagess

So I'm trying to align badge , username and message for streamlabs chat.
currently have made this : https://i.imgur.com/fydIZgn.png ,
but want it to look like this : https://i.imgur.com/QFw8YeA.png
so here is html and css not sure what im missing here but hope someone can help me with this
also if somebody does not have badges want his name to start from left without gaps which currently works with this setup.
<!-- chat item -->
<script type="text/template" id="chatlist_item">
<div data-from="{from}" data-id="{messageId}">
<span class="meta" style="color: {color}">
<span class="badges"></span>
<span class="name">{from}</span>
<span class="message">{message}</span>
</span>
</div>
</script>
#import url(https://fonts.googleapis.com/css?family=Roboto:700);
* {
box-sizing: border-box;
}
html, body {
height: 100%;
overflow: hidden;
}
body {
text-shadow: 0 0 1px #000, 0 0 2px #000;
background: {background_color};
font-family: 'Roboto';
font-weight: 700;
font-size: {font_size};
line-height: 1.5em;
color: {text_color};
}
#log>div {
animation: fadeInRight .3s ease forwards, fadeOut 0.5s ease {message_hide_delay} forwards;
-webkit-animation: fadeInRight .3s ease forwards, fadeOut 0.5s ease {message_hide_delay} forwards;
}
.colon {
display: none;
}
#log {
display: table;
position: absolute;
bottom: 0;
left: 0;
padding: 0 10px 10px;
width: 100%;
table-layout: fixed;
}
#log>div {
display: table-row;
}
#log>div.deleted {
visibility: hidden;
}
#log .emote {
background-repeat: no-repeat;
background-position: center;
background-size: contain;
padding: 0.4em 0.2em;
position: relative;
}
#log .emote img {
display: inline-block;
height: 1em;
opacity: 0;
}
#log .message,#log .meta {
vertical-align: top;
display: table-cell;
padding-bottom: 0.1em;
margin-left: 0.2em;
}
#log .meta {
width: 35%;
text-align: left;
padding-right: 0.5em;
white-space: nowrap;
text-overflow: clip;
overflow: hidden;
}
#log .message {
word-wrap: break-word;
white-space: initial;
width: 65%;
display: inline-block;
color: #fff;
}
.badge {
display: inline-block;
margin-right: 0.2em;
position: relative;
height: 1em;
vertical-align: middle;
top: -0.1em;
}
.name {
margin-left: 0.2em;
}
Removing display : inline-block should do the trick . Inline-block create block elements without line breakers . In this case badges , name and messages are separate block elements positioned next to each other . Each element will still have its own boundaries and properties like margin can be applied to each of them .
Since your requirement is to display them as inline , either change inline-block to 'inline' or remove the inline-block as span in already an inline element

How to keep components auto resizable while creating templates in React JS?

So I am trying to put a background image and then center the text to it, but when I change the screen size the text misaligns and moves to the top.
Here's my code:
import React from "react";
import UniversalValues from "../constants.js";
export default function Body() {
return (
<div>
<div className="Container">
<img
className="ResizeImage"
src="https://images.unsplash.com/photo-1533139143976-30918502365b?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max"
alt="Background not loading! X_X"
/>
<div className="TextField">
<h1 className="BGH1">WE DO IT TOGETHER</h1>
<h1 className="BGH1">SO LET'S CREATE</h1>
</div>
</div>
</div>
);
}
Here is my css file:
.App {
font-family: sans-serif;
text-align: center;
}
.BGH1 {
letter-spacing: 0.06em;
font-family: "Cinzel", serif;
font-size: 5rem;
position: relative;
}
.BrandPoint {
font-size: 3rem;
font-family: "Cinzel", serif;
padding-left: 3rem;
}
.Container {
position: relative;
}
.dropbtn {
background: transparent;
color: white;
padding-bottom: 10px;
font-size: 1.2rem;
font-weight: bold;
border: none;
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #33393f;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: white;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {
transition: transform 0.5s ease;
transform: scale(0.9);
color: #3eccb5;
border: 1px solid;
border-radius: 0.2rem;
border-color: #e0dede;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
.dropdown:hover .dropbtn {
transition: transform 0.5s ease;
transform: scale(0.9);
color: #3eccb5;
border: 1px solid;
border-radius: 0.2rem;
border-color: #e0dede;
}
.HeaderElem {
color: white;
padding-bottom: 10px;
font-size: 1.2rem;
}
.HeaderElem:hover {
transition: transform 0.5s ease;
transform: scale(0.9);
color: #3eccb5;
border: 1px solid;
border-radius: 0.2rem;
border-color: #e0dede;
}
.HeaderSeperator {
padding-left: 2rem;
}
.HeadUp {
position: fixed;
top: 0;
left: 0;
}
.ResizeImage {
height: auto;
width: 100%;
margin: 0;
padding: 0;
opacity: 0.99;
}
.TextField {
position: absolute;
bottom: 40%;
left: 35%;
color: white;
padding-left: 20px;
padding-right: 20px;
}
What I am getting vs What I wanted:
I want to pack this whole thing together and so it could just effectively change its shape according to the screen size. I have used Bootstrap but I am new to React and designing my entire website on codesandbox.io. Do let me know the best way to do so.
Thanks in advance.
I think your problem is purely HTML/CSS and not so much React. Thanks for flexbox centering content got a lot easier today.
Change your HTML like this:
<div>
<div class="Container">
<div class="imageContainer"></div>
<div class="TextField">
<h1 class="BGH1">WE DO IT TOGETHER</h1>
<h1 class="BGH1">SO LET'S CREATE</h1>
</div>
</div>
</div>
And your CSS like this:
.Container {
display: flex;
justify-content: center;
align-items: center;
background-color:blue;
position: relative;
color: white;
text-align: center;
height: 300px;
}
.imageContainer {
position: absolute;
width: 100%;
height: 100%;
opacity: 0.2;
background-image: url("https://images.unsplash.com/photo-1533139143976-30918502365b?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max");
background-position: center center;
}
Here is a fiddle test it: https://jsfiddle.net/gtqna9c1/7/
How it works
Instead of trying to center changing text by absolute positioning it is a lot easier to create conditions where the text is always centered, no matter what. The background image is now a simple background of a div that is covering your whole box.
The fiddle is simplified and coloured for clarity. Feel free to add paddings etc. as you wish.

Is there any way to make text responsive to color?

This might be a dumb question, but I have a background that has high contrasting colors and I want my <ul>'s <li>s to change color depending on what the background color is for each individual <li>. I really don't want to bloat my CSS by adding the color property to each one. Please can someone tell me if there is any way to do this.
I'm working an a CodePen project. It's a personal portfolio page. Just for reference I'll share it with you but it's not finished yet. I want the list under My Skills to be "color responsive" (if that even exists) so that the items at the bottom are easier to read.
Here is the pen.
Much appreciated!
Just using CSS, you can use mix-blend-mode to ul.
Chcek with css to ul element as mix-blend-mode: difference;
The mix-blend-mode property defines how an element’s content should blend with its background. This means that any images or text, borders or headings will be influenced by this property.
See here. Ref: Pen
var modeList = [
"normal",
"multiply",
"screen",
"overlay",
"darken",
"lighten",
"color-dodge",
"color-burn",
"hard-light",
"soft-light",
"difference",
"exclusion",
"hue",
"saturation",
"color",
"luminosity"
],
elem = document.querySelector(".box"),
propertyName = "mix-blend-mode",
modeElem = document.querySelector(".mode-name"),
duration = 2500;
var i = 0;
var activate = setInterval(function() {
if (i == modeList.length) i = 0;
var mode = modeList[i];
elem.style.mixBlendMode = mode;
modeElem.innerText = mode;
i++;
}, duration);
#charset "UTF-8";
* {
box-sizing: border-box;
}
body, html {
margin: 0;
height: 100%;
padding: 0;
-webkit-font-smoothing: antialiased;
}
.wrapper {
background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/14179/washington.jpg") no-repeat center center fixed;
background-size: cover;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-family: "Nocturno Display Medium 4", Georgia;
font-style: normal;
font-weight: normal;
font-stretch: normal;
height: 100%;
width: 100%;
}
.box {
justify-content: center;
align-items: center;
display: flex;
flex-direction: column;
font-size: 8vw;
border-top: 10px solid #BF0A30;
border-bottom: 10px solid #BF0A30;
line-height: 1;
background-color: #002B65;
color: white;
background-size: cover;
mix-blend-mode: hard-light;
height: 400px;
height: 50vh;
width: 100%;
text-align: center;
text-transform: uppercase;
}
.box p {
text-rendering: optimizeLegibility;
word-spacing: 5px;
margin: 0;
}
.mode-name-wrapper {
position: absolute;
bottom: 12vh;
left: 0;
right: 0;
color: #002B65;
text-align: center;
text-transform: uppercase;
font-size: 17px;
margin: 0 auto;
padding: 0;
width: 135px;
height: 135px;
border: 5px solid white;
background-color: #ddd;
border-radius: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.mode-name-wrapper:before {
content: "★";
display: block;
line-height: 1;
font-size: 20px;
margin-top: -20px;
margin-bottom: 10px;
color: #ef0d3c;
animation: spin 2.5s ease;
animation-iteration-count: infinite;
transform-origin: center center;
}
.mode-name {
position: relative;
left: 0;
right: 0;
animation: nudge 2.5s ease;
animation-iteration-count: infinite;
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
#keyframes nudge {
0% {
transform: translate(0, 0);
}
80% {
transform: translate(0, 0);
}
90% {
transform: translate(-10px, 0);
}
93% {
transform: translate(12px, 0);
}
95% {
transform: translate(-8px, 0);
}
100% {
transform: translate(0, 0);
}
}
<link rel="stylesheet" href="https://fonts.typonine.com/WF-003562-001299.css" type="text/css" />
<div class="wrapper">
<div class="box">
<p>Washington D.C.</p>
</div>
<small class="mode-name-wrapper">
<span class="mode-name">hard-light</span>
</small>
</div>

Centrally divided layout with animation (ONLY CSS)

IMPORTANT NOTE: only CSS/HTML, but not javascript (client does not allow it)
recently started the homepage of my site and wanted to make a centrally divided layout. Want to place the logo on the middle and one picture on top of it with a button to lead to the page, and one below it with the same function.
The animation should be a hover over the buttons (or defined area around it) as seen in the comp I did here:
GIF ANIMATION OF WHAT IS INTENDED
Similar to what is intended: https://jsfiddle.net/vja85zgL/
* {
margin: 0px;
padding: 0px;
}
#wrapper {
width: 80%;
height: 200px;
margin: auto;
}
#wrapper:hover #left:not(:hover) {
width: 25%;
transition: width 1s linear;
}
#wrapper:hover #right:not(:hover) {
width: 25%;
transition: width 1s linear;
}
#left {
width: 50%;
height: 100%;
background-color: lightblue;
display: inline-block;
position: relative;
transition: width 1s linear;
}
#innerleft {
position: absolute;
top: 100px;
width: calc(100% - 4px);
text-align: center;
border: 2px solid black;
}
#right {
width: 50%;
height: 100%;
background-color: lightgrey;
display: inline-block;
position: relative;
transition: width 1s linear;
}
#innerright {
position: absolute;
top: 100px;
width: calc(100% - 4px);
text-align: center;
border: 2px solid black;
}
#right:hover {
width: 75%;
transition: width 1s linear;
}
#left:hover {
width: 75%;
transition: width 1s linear;
}
<div id="wrapper">
<div id="left">
<div id="innerleft">
TITLE 1
</div>
</div><div id="right">
<div id="innerright">
TITLE 2
</div>
</div>
</div>
As seen, if hovering over the button, the background image behind the button shows itself "fully" (no rescaling), the logo (showed as B) moves down to 25% and the button not hovered scales down in size and font size and the image behind it slides under it where the user cannot see it properly (the user cannot see it by scrolling down).
If hovered on the other button the animation goes to the other button and image background.
There should be a delay of 2 seconds before the layout comes back to the starting position
DETAILS:
NO JAVASCRIPT ALLOWED, client doesn't allow usage
Should be responsive, so no hovering on touch devices
The image must not resize or loose proportion
Full screen layout
Mouse simulates user.
Animation should return to initial position after 3 seconds if mouse is not hovering
Initial position is 50%-50% (almost, due to the logo which is 150x150px)
End position should be 75%-25%.
Have been loosing my mind the last 2 days wondering how to do it as I am a beginner at CSS but didn't find a way yet.
Any help would be appreciated!
Available code of what has been done already to the design (total mess...):
#business-top {
height:50%
width:100%
}
#business-button {
height:3em;
width:12em;
background-color:#2B2A2A;
border: .2em solid #ff7600;
border-radius:1.8em;
margin:auto;
margin-top:3em;
}
#logo-separator {
text-align:center;
}
.separator {
display: block;
position: relative;
padding: 0;
height: 0;
width: 100%;
max-height: 0;
font-size: 1px;
line-height: 0;
clear: both;
border: none;
border-top: 1px solid #ff7600;
border-bottom: 1px solid #ff7600;
}
#logo {
margin:auto;
max-width:150px;
display:inline-block;
overflow:hidden
margin-top:-75px
}
#photography-bottom {
height:50%
width:100%
}
#photography-button {
height:3em;
width:12em;
background-color:#2B2A2A;
border: .2em solid #ff7600;
border-radius:1.8em;
margin:auto;
margin-top:3em;
}
h1 {
color:#ff7600;
text-align:center;
font-size:1.4em;
vertical-align:middle;
line-height:2.2em
}
<div id="business-top"
<a href="www.lluisballbe.smugmug.com">
<div id="business-button">
<h1>BUSINESS</h1>
</div>
</a>
</div>
<div id="logo-separator">
<div class="separator"></div>
<div id="logo"><img src="https://lluisballbe.smugmug.com/Assets-for-website/i-CsMnM3R/0/Th/800x800-round-Th.png"</div>
</div>
<div id="photography-bottom"
<a href="www.lluisballbe.smugmug.com">
<div id="photography-button">
<h1>PHOTOGRAPHY</h1>
</div>
</a>
</div>
If you increase area of buttons once hovered , then you may have some results in CSS only:
trick comes from pointer-events and pseudo to increase hoverable area
/* tricky part */
div {
width: 100%;
pointer-events: none;
overflow: hidden;
transition: 1.5s;
}
div:hover {/* will be catch by child with pointer-events auto */
flex: 3;
}
div:first-child {
background: turquoise;
}
div a {
pointer-events: auto;/* if a is hovered, so is its parent */
position: relative;/* this could be for the div parent if you want to cover its area */
padding: 5px;
border-radius: 0.25em;
border: 3px solid;
box-shadow: 2px 2px 5px;
color: #222;
background: #aaa;
}
div a:hover:before {/* increase size of button only once hovered */
content: '';
position: absolute;
top: -200px;/* coordonates used to increase pseudo size from its relative position parent. tune to your needs */
bottom: -200px;
width: 100%;
}
/* layout */
body,
div {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
div {
flex: 1;
}
hr {
width: 100%;
height: 5px;
background: red;
text-align: center;
}
hr:before {
content: url(http://dummyimage.com/50x50);
display: inline-block;
height: 50px;
border-radius: 50%;
overflow: hidden;
margin-top: -25px;
}
html,
body {
height: 100%;
width: 100%;
margin: 0;
}
<div>
button style
</div>
<hr/>
<div>
button style
</div>
From your update snippet :
html,
body {
height: 100%;
width: 100%;
margin: 0;
}
body {
display: flex;
flex-direction: column;
}
h1 {
margin: 0;
}
a {
display: inline-block;
}
#business-top {
display: flex;
flex: 1;
width: 100%;
align-items: center;
justify-content: center;
text-align: center;
}
#business-button {
height: 3em;
width: 12em;
background-color: #2B2A2A;
border: .2em solid #ff7600;
border-radius: 1.8em;
margin: auto;
}
#logo-separator {
text-align: center;
}
.separator {
display: block;
position: relative;
padding: 0;
height: 0;
width: 100%;
max-height: 0;
font-size: 1px;
line-height: 0;
flex: 0;
border-top: 1px solid #ff7600;
border-bottom: 1px solid #ff7600;
}
#logo {
margin: auto;
max-width: 150px;
display: inline-block;
overflow: hidden;
margin: -75px;
position: absolute;
}
#photography-bottom {
display: flex;
flex: 1;
width: 100%;
align-items: center;
justify-content: center;
}
#photography-button {
height: 3em;
width: 12em;
background-color: #2B2A2A;
border: .2em solid #ff7600;
border-radius: 1.8em;
margin: auto;
}
h1 {
color: #ff7600;
text-align: center;
font-size: 1.4em;
vertical-align: middle;
line-height: 2.2em
}
#business-top,
#photography-bottom {
pointer-events: none;
position: relative;
z-index: 1;
transition: 1s;
/* min-height: 200px; you ma want this to avoid logo and button to overlap */
}
#business-top a,
#photography-bottom a {
pointer-events: auto;
}
#business-top:hover,
#photography-bottom:hover {
flex: 3;
}
#business-top a:hover:before,
#photography-bottom a:hover:before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
<div id="business-top">
<a href="www.lluisballbe.smugmug.com">
<div id="business-button">
<h1>BUSINESS</h1>
</div>
</a>
</div>
<div id="logo-separator">
<div class="separator"></div>
<div id="logo"><img src="https://lluisballbe.smugmug.com/Assets-for-website/i-CsMnM3R/0/Th/800x800-round-Th.png"> </div>
</div>
<div id="photography-bottom">
<a href="www.lluisballbe.smugmug.com">
<div id="photography-button">
<h1>PHOTOGRAPHY</h1>
</div>
</a>
</div>
http://codepen.io/anon/pen/qbvgga