Tips for smoothly animating without overlapping to the far right position

Here is the code I have:

body {
  font-size: initial;
  line-height: initial;
}
@-webkit-keyframes slide {
  from {
    margin-left: 0%;
  }
  to {
    margin-left: 30%;
  }
}
@-webkit-keyframes turn {
  0% {
    -webkit-transform: rotate(30deg);
  }
  20% {
    -webkit-transform: rotate(60deg);
  }
  60% {
    -webkit-transform: rotate(30deg);
  }
  80% {
    -webkit-transform: rotate(30deg);
  }
  100% {
    -webkit-transform: rotate(30deg);
  }
}
.char {
  display: inline-block;
  -webkit-animation-name: slide, turn;
  -webkit-animation-duration: 5s;
  -webkit-animation-timing-function: ease-in-out;
  -webkit-animation-iteration-count: one;
  -webkit-animation-direction: alternate;
  text-align: center;
  font-size: 2.5em;
  font-weight: bold;
}
<!DOCTYPE html>
<html>

<head>
  <link href="http://www.w3schools.com/lib/w3.css" rel="stylesheet">
</head>

<body>
  <div>
    <div>
      <span class="char">I</span>
      <span class="char"> </span>
      <span class="char">s</span>
      <span class="char">h</span>
      <span class="char">o</span>
      <span class="char">u</span>
      <span class="char">l</span>
      <span class="char">d</span>
      <span class="char"> </span>
      <span class="char">n</span>
      <span class="char">o</span>
      <span class="char">t</span>
      <span class="char"> </span>
      <span class="char">s</span>
      <span class="char">t</span>
      <span class="char">a</span>
      <span class="char">c</span>
      <span class="char">k</span>
      <span class="char">.</span>
    </div>
  </div>
</body>

</html>

Instead of stacking up, I want the text to fly out of the screen. I attempted to add overflow: hidden in the body, but it didn't have the desired effect.

Do you know of a solution for this issue?

Answer №1

To ensure your text stays on the same line, apply the CSS property white-space: nowrap; to the parent element:

body {
  font-size: initial;
  line-height: initial;
}
@-webkit-keyframes slide {
  from {
    margin-left: 0%;
  }
  to {
    margin-left: 30%;
  }
}
@-webkit-keyframes turn {
  0% {
    -webkit-transform: rotate(30deg);
  }
  20% {
    -webkit-transform: rotate(60deg);
  }
  60% {
    -webkit-transform: rotate(30deg);
  }
  80% {
    -webkit-transform: rotate(30deg);
  }
  100% {
    -webkit-transform: rotate(30deg);
  }
}
.char-container {
  white-space: nowrap;
}
.char {
  display: inline-block;
  -webkit-animation-name: slide, turn;
  -webkit-animation-duration: 5s;
  -webkit-animation-timing-function: ease-in-out;
  -webkit-animation-iteration-count: one;
  -webkit-animation-direction: alternate;
  text-align: center;
  font-size: 2.5em;
  font-weight: bold;
}
<!DOCTYPE html>
<html>

<head>
  <link href="http://www.w3schools.com/lib/w3.css" rel="stylesheet">
</head>

<body>
  <div>
    <div class="char-container">
      <span class="char">I</span>
      <span class="char"> </span>
      <span class="char">s</span>
      <span class="char">h</span>
      <span class="char">o</span>
      <span class="char">u</span>
      <span class="char">l</span>
      <span class="char">d</span>
      <span class="char"> </span>
      <span class="char">n</span>
      <span class="char">o</span>
      <span class="char">t</span>
      <span class="char"> </span>
      <span class="char">s</span>
      <span class="char">t</span>
      <span class="char">a</span>
      <span class="char">c</span>
      <span class="char">k</span>
      <span class="char">.</span>
    </div>
  </div>
</body>

</html>

By using <span> tags with the CSS property white-space: nowrap;, the text will remain on the same line without any wrapping, maintaining the desired inline display.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for displaying the date of a JSON response in Angular HTML format?

When working with Angular HTML, I am looping through a JSON array using ngFor and accessing the birth date data like this: <td>{{item.customer_info.birth_date}}</td> The data is being displayed as ddMMyyyy format, but I would like to change it ...

Tips for including vertical lines within text boxes to distinguish elements

I've been working on a simple form using CSS and HTML, but I'm struggling to add vertical lines to separate my text from the radio buttons. Right now, I'm just using '|' to divide them, but it's not the most visually appealing ...

Tips for Providing Real-Time Data for a Dynamic Chart in d3

I have a line chart sample from D3, and the issue I'm facing is that I need to continuously feed live data from a server at certain time intervals and use D3 to draw the chart based on this dynamic data. Despite my efforts to search for a solution, I ...

What is the best way to choose all elements except for <body>? Alternatively, how can <body> be styled to its default appearance?

Web browsers often apply default styles to different elements, but users have the option to override these defaults using custom stylesheets. I personally like to customize these default styles with my own, for example: * {padding:0; margin:0; } However ...

Discovering back-to-back days

I am currently working on a PHP script that utilizes a MySQL database to calculate various climatological parameters based on different variables. While I have successfully completed most of the calculations, there is one particular task that I am struggli ...

The Three JS on the website is error-free, yet it fails to function properly

I've been attempting to replicate the example three.js page on my own website, complete with a canvas for the 3D animation. However, I'm encountering an issue where nothing is displayed, despite no errors appearing. I've tried troubleshootin ...

Creating dynamic web content using KaTeX and Node.js

When I attempt to display a complex formula using HTML and CSS, I encounter difficulties. Instead of the desired output, my screen is filled with confusing unicode characters. To resolve this issue, I decided to use KaTeX. I downloaded KaTeX into the dire ...

Creating a CSV file using an AJAX request in PHP

In my current project involving PHP AJAX DATATABLE within the Drupal framework, I have successfully developed a function to create a CSV file from table records. This function is triggered by clicking a button in HTML or accessing a specific URL. The PHP ...

Looking for a simple method to generate a text-only dropdown link in Bootstrap 4 without using a button?

Is there a simple method to create a text-only dropdown link in Bootstrap 4 without using a button? Or do I have to adjust the padding and buttons using CSS to make the "Delivery" dropdown blend in with the rest of the text? I've searched online and ...

Place in the Middle of a Bootstrap Container

Struggling with aligning the elements of a Bootstrap well in the center? The badge is off to the side instead of below the arrows, and the vote buttons are not centered within the well. Check out the code snippet below: HTML: <div class="col-md-1 ...

What is the best way to place this dropdown in a fixed position within a parent element with overflow scrolling

I am facing an issue with a dropdown menu inside a parent div. The parent div has a fixed height and is set to overflow: auto. My goal is to have the menu extend beyond the boundaries of the parent when opened, but currently it just increases the height of ...

Blog entries alternating between a pair of distinct hues

I want to create a design where each post container has a different color from the one next to it. Essentially, I would like the containers to alternate between two distinct colors. The left side shows how it currently appears, while the right side depict ...

The current_time() function displayed an incorrect time value

When I utilized the current_time() function in PHP to retrieve the current time, it displayed an incorrect time. Instead of the correct time, it is showing 12 hours and 30 minutes earlier than the actual current time, even after modifying the php.ini file ...

Mastering the use of Quasar variables in your scss styles is crucial for optimizing your

I recently set up a project using Vue3 and Quasar by running vue add quasar. However, I am struggling to figure out how to utilize Quasar sass/scss variables. According to the documentation, I should use the following syntax: <style lang="scss&quo ...

Enhancing bar border with the addition of a separator

Our current situation is similar to this: https://i.stack.imgur.com/Luj1S.png but our goal is to have a chart with separators on both sides of the age brackets, like this: https://i.stack.imgur.com/03UpO.png In order to achieve this, we have utilized t ...

issue with fetching response from ajax post call in slim framework 3

Update: The issue has been resolved. The correct localhost address for the ajax request should have been 127.0.0.1 instead of 121.0.0.1 On my client side, I am using the following code to send a POST request to localhost/login. <html> <title> ...

Refreshing an iframe located on disparate domains

There is a webpage called "main.jsp" within the domain "domain1". This page contains an iframe that loads content from another domain known as "domain2". Essentially, "main.jsp" serves as a common content platform, with the iframe displaying content from v ...

When the button is left alone, its color will change

<!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <bod ...

Hovering over an image will not cause the floating header to appear

My attempt to create a header that fades with scroll and appears on hover is working perfectly, except for the cat pictures in the Portfolio section. Despite adjusting z-indexes and trying various solutions, the header just won't show up over the h4 e ...

Swap out the HTML tags with JavaScript code

I've been looking everywhere, but I couldn't find the answer. Here is my issue / question: I have a page from CKEDITOR with: var oldText = CKEDITOR.instances.message.getData(); So far, so good. The string looks something like this: <table ...