The div escapes the container and falls down to the one below it

I am encountering an issue with the layout of my outer container, which contains a column of numbers and animated text. The problem arises when the animated text, supposed to be beside the number column, drops under the numbers before bouncing back up as it reaches the outer container, eventually breaking out.

Despite attempting to use the word-wrap: property on the animated text div, I have not been able to resolve the issue. It seems like a combination of floats, overflows, and word-wrap might be the solution, but I cannot seem to find the correct mix.

The animation is being handled by typed.js plugin.

You can view a working example on this fiddle

Answer №1

By removing the display: inline-block property from the code-block class, it seems to eliminate the issue of the code block jumping below the line numbers. However, due to the way the JS script adds and removes characters, there may still be a brief moment of jumping when lines are added or removed, though this may not be directly related to the initial problem.


Edit 1

It appears that the culprit causing the temporary jump is the white-space:pre attribute on the span containing the text input. Changing this to white-space: pre-line; seems to resolve the jumping problem.

To address this issue, I would recommend two simple adjustments:

  1. Remove the display: inline-block; from the .code-block class; and
  2. Replace white-space: pre; with white-space: pre-wrap for the span housing the code input.

To see the changes in action, check out this fiddle: jsfiddle

Answer №2

To make the width smaller than the main container, try using em instead of px:

.code-block {
    display: inline-block;
    padding-top: 3px;
    width: 30em;
}

Just a heads up, changing to em didn't have an impact on the appearance but did improve performance and reduced code length:

$(function(){
    $(".code-animate").typed({
        strings: ["    <p>Lorem ipsum dolor sit amet, ei sit atomorum forensibus, pro ad denique vituperata. His ni.</p>"],
        typeSpeed: 1,
        backSpeed: 50,
        contentType: 'text',
        loop: true
    });
});

See the working fiddle below:

https://jsfiddle.net/gjab03dx/8/

I had to eliminate word wrapping for it to function properly - quite an interesting challenge! Now I'm eager to tackle the remaining issues!

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

Attempting to retrieve XML/JSON

I am struggling with extracting the first 15 words from a file using the API. I have attempted to do it with both XML and JSON, but keep encountering this error: XMLHttpRequest cannot load No 'Access-Control-Allow-Origin' header is present on th ...

Accessing vector features by clicking in close proximity to, but not directly on, a vector in OpenLayers

I'm working with an Open Street Map that includes vectors (lines) displaying on the roads. Currently, I can only retrieve information about a vector by clicking directly on its pixels. Is there a way to make it so that I can click near the vector (a f ...

The "next" button on my carousel is unresponsive and the automatic transitioning feature is not working

I'm having trouble implementing a carousel on my website. The next/previous buttons and automatic slides are not functioning properly. <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <!- ...

What is the best way to design a grid consisting of 14 divs that span the entire width of the browser screen, incorporating dividers to separate different groups, utilizing a combination of html,

I am interested in creating a layout with two rows of divs that span the entire width of the screen, with a total of 14 divs in each row. These divs are fixed in size and grouped by color, with dividers separating each color group. I am hoping to achieve ...

Validation of HTML5 forms using jQuery

I am in need of a jQuery-based validation library that will kick in when the browser does not support HTML5 for specific attributes like 'required' or 'placeholder'. After looking around, I have come across several libraries but they ar ...

"Enhance your Vue.js application with the powerful capabilities of vue3-easy

I am currently working on a Vue.js project utilizing the "vue3-easy-data-table" library and following the style recommendations outlined on this particular webpage: Despite attempting to apply the following CSS properties: --easy-table-body-even-row-font ...

Tips for configuring Webstorm to automatically change double quotes to single quotes when reformatting source code

After using cmd + alt + l in Webstorm to format my JavaScript code, I noticed that double quotes are used instead of single quotes. How can I configure Webstorm to automatically change the double quotes to single quotes in my code? ...

Animating SVG from upper left corner to lower right corner

I am looking to create an animation on this SVG that starts from the top left and ends at the bottom right, similar to a gif. You can view the example I want to replicate in the following link: body { background: black } path { fill: white; } /* ...

When using PHP submit, the text input from dynamically generated JS fields is not being posted

My HTML form includes a table of text inputs that I intend to use for generating an SQL INSERT query. The issue I am facing is that my manually inputted table has 5 text inputs, with the option for users to add more. The additional input fields are being c ...

The YUI framework is skilled at creating new lines while erasing the old ones

I am looking to create a line when the mouse is clicked, and remove the previously drawn line. View the code on jsfiddle.net at this link. While my current code successfully draws a line when the mouse is clicked, it does not remove the previous line. I n ...

The text relentlessly presses the button within the confines of bootstrap

I am facing an issue with the alignment of the buttons in my HTML code. As the text inside the <p> tag grows, it pushes the button to the right. I want all the buttons to be positioned in the bottom-right corner of every div regardless of the text si ...

What causes the data property to supersede the return false in a jQuery ajax call?

Below is a block of code that I am currently working with: $("#contact_container form, #contact_details form").live( "submit", function(event) { $.ajax({ type: this.method, url: this.action, data: this.s ...

Create a list item that includes an image with a corresponding label positioned beneath it

Currently attempting to convert my design into HTML and CSS for the first time, I've hit a roadblock with this particular task: I'm trying to create a series of white boxes, with each item having a white border. However, I'm struggling to c ...

Centering the scrollIntoView feature on mobile devices is presenting challenges with NextJS applications

Description While navigating on mobile browsers, I'm facing a challenge with keeping an element centered as I scroll due to the browser window minimizing. I've experimented with different solutions such as utilizing the react-scroll library and ...

Ways to access the values of checkboxes that are initially checked by default

Recently, I was working on a project that involved multiple checkboxes. My goal was to have the checkboxes pre-checked with values in the form (using reactive form). Users should be able to unselect the boxes as they wish and the data would be stored accor ...

Modify the icon in the header of MaterializeCSS Collapsible when it is opened

I'm struggling to figure out how to change the icon of a toggled collapsible element. I have been reviewing their documentation but am having trouble making it work as intended. $('.collaps_roles_permission').collapsible({ accordion: tr ...

Adding fresh data to a C3.js line graph

I am attempting to dynamically update a C3.js line chart using a function that retrieves a set of x and y values from a database. The function I want to use for inserting the data is: function insertGraph(yAxis, xAxis, Header) { setTimeout(function () ...

Deciphering image coordinates provided for incorporating an animated image component into a form

Is there a way to store the X:Y coordinates of a user click on an animated image by examining the php $_POST array? My issue is that I am able to retrieve input submission data from static images, but not from the animated one. Below is the full HTML page ...

Adjust link when scrolling through the webpage

I am looking to update the URL while scrolling instead of changing the menu class. Here's the reference I found: https://codepen.io/anon/pen/LdLgNo I made some modifications by adding push state, but I'm facing an issue with a fixed header. I ...

Transferring data between functional components in ReactJS and dealing with the output of [object Object] or undefined

I'm struggling with passing a prop in functional components that are both located in the same .js file. I previously attempted to seek help for this issue, but unfortunately, it wasn't productive. My goal is to extract the member_id from the GET ...