I have a problem with text clipping, practically when I set the div to a lower width than the text, it disappears. I want it to clip words as it reduces its size... I tried with overflow: hidden and also text-overflow: clip but it's not working as I want. Here's the code, thank you in advance.
.finalCutStyleButton{
width: 90mm;
height: 20mm;
background-color: #b3be9e;
animation: test 2s ease-in;
}
#keyframes test{
from{
width: 90mm;
}
to{
width: 30mm;
}
}
.title{
font-size: 10mm;
font-family: 'SFProBold', sans-serif;
font-weight: bold;
display: inline-block;
width: auto;
}
<div class = "finalCutStyleButton adjustPadding">
<h1 class = "title">VIDEO EDITING</h1>
</div>
try adding same keyframe logic to the text:
.finalCutStyleButton {
width: 90mm;
height: 20mm;
background-color: #b3be9e;
display: flex;
align-items: center;
animation: test 2s ease-in;
}
#keyframes test {
from {
width: 90mm;
}
to {
width: 30mm;
}
}
.title {
font-size: 10mm;
margin: 0 0;
font-family: "SFProBold", sans-serif;
font-weight: bold;
display: inline-block;
min-width: 100%;
white-space: nowrap;
overflow: hidden;
}
<div class="finalCutStyleButton adjustPadding">
<h1 class="title">VIDEO EDITING</h1>
</div>
Related
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%;
}
}
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
I need help with this project. When I hover over the textarea, the box expands:
body {
background-color: black;
}
p {
font-family: Sans-Serif;
color:white;
}
#keyframes do {
to {width: 500px; height: 100px;}
}
#keyframes undo {
to {width: 50px; height: 50px}
}
#entering {
animation-name: undo;
animation-duration: .5s;
animation-fill-mode: forwards;
text-align: left;
width: 50px;
height: 50px;
border: none;
font-family: Times;
color: black;
background-color: white;
resize: none;
overflow: hidden;
}
/* The animation-fill-mode doesn't keep
* the width attribute for the zoom out
* animation above.
*/
#entering:hover {
animation-name: do;
animation-duration: .5s;
animation-fill-mode: forwards;
}
#text {
width: 500px;
height: 100px;
}
<div id = "text">
<textarea id = "entering">SAMPLE
</textarea>
</div>
<p>An example of my project.</p>
However, I want to make it so that after the animation is completely finished, the height and width attributes stay the same so the undo animation will work. What is the most CSS oriented solution?
For this use case, I'd suggest using a transition on hover instead.
This way is easier than going with animation
#entering {
transition: .5s ease;
}
#entering:hover {
width: 500px;
height: 100px;
}
full code:
body {
background-color: black;
}
p {
font-family: Sans-Serif;
color:white;
}
#entering {
transition: .5s ease;
text-align: left;
width: 50px;
height: 50px;
border: none;
font-family: Times;
color: black;
background-color: white;
resize: none;
overflow: hidden;
}
#entering:hover {
width: 500px;
height: 100px;
}
#text {
width: 500px;
height: 100px;
}
<div id = "text">
<textarea id = "entering">SAMPLE
</textarea>
</div>
<p>An example of my project.</p>
I made this CSS typewriter animation however, I'm unable to make it responsive.
The below is my code:
HTML:
<div class="animation">
<p>CRISTIANO RONALDO</p>
</div>
CSS:
.animation p{
color: #D64933;
font-family: 'Lato', cursive;
font-size: 50px;
white-space: nowrap;
overflow: hidden;
width: 30em;
animation: title 7s steps(70, end);
margin-bottom: 40px;
}
#keyframes title{
from { width: 0; opacity: 0.0;}
to { opacity: 1.0; }
}
I want the animation to start from center of the page and also be responsive. Any thoughts on how it can be achieved?
Link to CodePen
Pretty straight forward with flexbox.
wrap your animation in a container.
set display to flex
justify-content and align items to center
set height of body html and container to 100%
set font size to a view height so it remains responsive
body, html{
height: 100%;
}
.container{
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.animation p{
color: #D64933;
font-family: 'Lato', cursive;
font-size: 10vh;
white-space: nowrap;
overflow: hidden;
width: 30em;
animation: title 7s steps(70, end);
margin-bottom: 40px;
}
#keyframes title{
from { width: 0; opacity: 0.0;}
to { opacity: 1.0; }
}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<div class="animation">
<p class="text-center">CRISTIANO RONALDO</p>
</div>
</div>
I'm not saying it's the best fix but at least it works (tho there is some shaking) :
/*CSS*/
.animation {
width: 100%;
text-align: center;
}
.animation p{
margin: 0;
position: absolute;
left: 50%;
transform: translate(-50%, -50%);
color: #D64933;
font-family: 'Lato', cursive;
font-size: 50px;
white-space: nowrap;
overflow: hidden;
width: 30em;
animation: title 3s steps(70, end);
margin-bottom: 40px;
}
I've already run my code through a validator, so there are no syntax errors, but I can't figure out what's going on. Nothing I do changes the "p" elements in my code. I've tried styling the p class. I've tried wrapping them in a "div" tag and stylizing that, but it just seems to keep inheriting the body properties. If I want to style the text at all, I have to do it through the body properties.
Here's the HTML.
<div id="topBar"><img src="images/logo.png" alt="Escaping Shapes"/></div>
<div id="rope"><img src="images/rope2.png" alt="Bottom of logo border"/></div>
<p>Yarrrrgh! Shapes be escaping from below the surface of the Web! Push'em back down below the page as fast as ye can!</p>
<p class="bold">Your time: <span id="time">(not attempted yet)</span></p>
<div id="box">
</div>
Here's the CSS for the body:
body {
width: 100%;
font-family: Verdana, Geneva, sans-serif;
margin: 0;
background-color: #ecf0f1;
font-weight: bold;
text-align: center;
}
Here's the CSS for the "p" element that does NOTHING for me lol.
p {
position: relative;
font-weight: bold;
width: 20px;
margin: auto;
text-align: center;
}
Not sure what's going on, but any help would be greatly appreciated. I can provide more of my code if necessary.
EDIT My Entire CSS:
body {
width: 100%;
font-family: Verdana, Geneva, sans-serif;
margin: 0;
background-color: #ecf0f1;
font-weight: bold;
text-align: center;
}
#topBar {
background-color: #2980b9;
height: 120px;
width: 100%;
position: relative;
}
#topBar img {
display: block;
margin: 0 auto;
width: 600px;
position: relative;
top: 25px;
left: -85px;
}
#box {
background-color: #0ff;
height: 150px;
width: 150px;
display: none;
position: relative;
top: 0;
margin-top: 0;
margin-bottom: 10px;
opacity: 0.9;
box-shadow: 10px 10px 5px #7e7e7e;
-webkit-transition:all 0.1s linear;
-moz-transition:all 0.1s linear ;
-ms-width:all 0.1s linear ;
-o-width:all 0.1s
}
#box:active {
box-shadow: none;
top: 10px;
margin-bottom: 0;
-webkit-transform:scale(0.25, 0.25);
-moz-transform:scale(0.25, 0.25) ;
-ms-width:scale(0.25, 0.25) ;
-o-width:scale(0.25, 0.25) ;
}
#box:hover {
opacity: 1;
}
#rope {
background-repeat: repeat-x;
background-image: url(images/rope2.png);
width: 100%;
position: relative;
top: -25px;
.bold {
font-weight: bold;
}
p {
position: relative;
font-weight: bold;
width: 20px;
margin: auto;
text-align: center;
}
You have not closed off -o-width:all 0.1s
with a semi-colon under your #box css properties This is your problem.
You also haven't closed off your #rope properties }
It seems that the p styles are being applied to the p. I tried by setting the font color via the p rule and it works: http://jsfiddle.net/L2q1Lbzj/
body {
width: 100%;
font-family: Verdana, Geneva, sans-serif;
margin: 0;
background-color: #ecf0f1;
font-weight: bold;
text-align: center;
}
p {
position: relative;
font-weight: bold;
width: 20px;
margin: auto;
text-align: center;
color: red;
}
There is no problem in your css.
The <p> is working good enough in your given code.
CSS properties overlap each other.So be careful about this.
jsfiddle
edit:
as your new edit
you are missing closing }
write
#rope {
background-repeat: repeat-x;
background-image: url(images/rope2.png);
width: 100%;
position: relative;
top: -25px;
}
instead of
rope {
background-repeat: repeat-x;
background-image: url(images/rope2.png);
width: 100%;
position: relative;
top: -25px;
link