What causes the inability to separate the span size from the parent div when enlarging the span width?

Check out this Relevant Fiddle: https://jsfiddle.net/promexj1/1/

I'm working on adjusting the widths of two child spans within a parent div to be slightly smaller than the parent itself (due to starting translation 10px to the right for one of the spans). However, I've noticed that when these spans are rendered in the DOM, they default back to half the size of the parent div (potentially due to having two spans).

I've added a black border to the span elements to better visualize their sizes.

Is there a way to unlink this inherited size divided among the child spans and instead have them render based on their individual styling widths?

Answer №1

If you have spans within a flex container, you can maintain their fixed size by using flex-shrink: 0.

Learn more about flex-shrink property here.

The flex-shrink CSS property determines how flex items shrink when there is not enough space in the flex container.

To quickly address your demo issue, I added the flex-shrink: 0 property to the rule for .scrollable_section and adjusted the translateX value for .verse-two. However, since it wasn't clear how you were handling text overflow, the focus may not be solely on that aspect of the problem:

function toggleTransition() {
  var example = document.getElementById('example');
  example.classList.toggle('next-verse');
}
/* CSS styles */
<HTML code>

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

Flexbox not rendering correctly on IE and Chrome browsers

Initially, I avoided using flexboxes because of concerns about older browser support. However, the alternative involved floats, margins, z-indexes, and resulted in a layout that was visually unattractive. Despite setting specific dimensions for the left-h ...

A guide on incorporating multiple nested loops within a single table using Vue.js

Is it possible to loop through a multi-nested object collection while still displaying it in the same table? <table v-for="d in transaction.documents"> <tbody> <tr> <th>Document ID:</th> &l ...

Different body background color changes every second

I have a function called makeRandColor that generates a random color using RGB and template string literals. However, I am struggling to figure out how to make it work every second. I tried using setInterval but it doesn't seem to be functioning prope ...

Efficiently Organizing Database Content: Ordering List with Dropdown Menu and Pagination

Is the title of this script clear? Essentially, I developed a PHP script to retrieve data from a database and display it. I then implemented code to use a drop-down menu for sorting that data. Everything was working fine until I attempted to add pagination ...

Creating a personalized navbar design using Bootstrap

I'm attempting to build a navbar using bootstrap 4: However, I am uncertain of how to achieve this :/, can anyone offer any advice?! I am specifically interested in the lines on the left and right of the navbar, as well as the image centered in the m ...

Struggling to remove the image tag from the jQuery ajax response

My web app is designed to send an ajax post request to a PHP script, which then returns a chunk of HTML data. This HTML includes an image and a table of information. The challenge I'm facing is how to extract the image from the rest of the HTML so tha ...

React.js onClick does not display the dropdown

Hello, I have a question regarding my navbar icon functionality. When I click on the icon, it is supposed to open a dropdown menu. However, although the div name changes when clicked, the CSS properties remain the same as the initial class. I am unsure w ...

What is the best approach to obtain an inventory of inputs from a particular viewpoint?

I am facing an issue where I have a list of products that require the quantities to be returned along with the reason for return. However, I cannot modify the referenced model as it has an impact on multiple values. Can someone guide me on how to retrieve ...

Modifying the color of the Payment Button in a Stripe Pop-up

I have successfully implemented the Stripe payment method on my leadpages, and everything is functioning well. However, I would like to customize the color of the Pay button to match the design in the attached image. https://i.sstatic.net/4mDrH.png Below ...

Attempting to extract data from an HTML table and store it in an array using JavaScript with the help of jQuery

Currently, I am faced with a challenge involving extracting values from an HTML table and storing them in a 2-dimensional array using JavaScript. jQuery seems like the ideal solution for this task. While I have managed to get the indices working properly, ...

Can someone provide guidance on utilizing parentheses in HTML code?

I am facing an issue in my Angular project while using the WordPress API. The problem lies in the API address structure which includes "" like this: <img src="{{importantvideo.better_featured_image.media_details.sizes.["covernews-med ...

Tips for updating text in a freshly opened window using JQuery or JavaScript

I have a function that is triggered by a button click to open a new window or tab, display an alert, and update text. Here is the code snippet: function nWin(p) { var setStyle = "<style rel='stylesheet'>\ .vTop {\ ...

The height and alignment of the <a> tag and <p> element vary within a flex container

Currently, I am in the process of constructing a bottom navigation bar for a blog page. This navigation bar will allow users to easily navigate between the last blog entry, the main blog home/index, and the upcoming post. However, when the user reaches the ...

The function `jQuery .html('<img>')` is not functional in Firefox and Opera browsers

This particular code snippet jq("#description" + tourId).html('<b>Opis: </b> '+ data); has been tested and functions correctly in Internet Explorer, Firefox, and Opera. However, when it comes to this specific piece of code jq("#i ...

How do I resolve the issue of a non-iterable 'int' object?

1 How can I troubleshoot the error that is popping up? I believe the issue may be related to it being a dictionary. Any suggestions on how to fix this problem? views search(request): if "q" in request.GET: querystring = request.GET.get(" ...

Leveraging mdbvue within the SAFE Network, style elements are noticeable by their absence

I checked out this handy tutorial But what really caught my attention was this tutorial: After following along, I ended up with the result below: https://i.sstatic.net/asgZs.png It's clear that something is missing in terms of style. As a novice i ...

100% width with a pixel offset

In the past, I have achieved this by using padding. The concept is to have two div elements positioned side by side, where one has a width of 100% and the other has a fixed width of 50px. Here's a rough illustration: ------------------------------- ...

"Enhance the Navbar with a pop of color by changing

https://i.sstatic.net/dHKsV.pngMy Navbar is already defined and working perfectly, but I want to add a full-page background to the Navbar links. Currently, on mobile devices, the link backgrounds do not cover the entire page horizontally and instead look l ...

Manage the placement of elements using CSS

Having an issue here. The blue-colored elements are showing up vertically, but I want them to be displayed horizontally. I've tried various methods but haven't been able to solve the problem. Providing just the code for the items below due to len ...

Utilizing drop-down pagination with Jquery

<select multiple> <option></option> <option>a1</option> <option>b1</option> <option>c1</option> <option>d1</option> . . . . . <option>u100</option> < ...