How can flexbox ensure that the width won't shrink?

When I set a fixed width for my 'left box', the width shrinks if the content on the right is too long. How can I prevent this from happening?

.flex {
  display: flex;
}

.left {
  width: 10px;
  height: 10px;
  border: 1px solid;
}

.right {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}
<div class="flex">
  <div class="left">

  </div>
  <div class="right">
    hello world this and that etc hello world this and that etc hello world this and that etc hello world this and that etc hello world this and that etc
  </div>
</div>

Answer №1

Specify the leftbox flex-shrink property to have a value of0:

.flex {
  display: flex;
}

.left {
  width: 10px;
  height: 10px;
  border: 1px solid;
  flex-shrink: 0;
}

.right {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
}
<div class="flex">
  <div class="left">

  </div>
  <div class="right">
    hello world this and that etc hello world this and that etc hello world this and that etc hello world this and that etc hello world this and that etc
  </div>
</div>

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

Sliding off the canvas - concealed navigation

I have implemented CSS to hide a menu on mobile: #filter-column { position:absolute; left:-400px; } However, I want the menu to slide in from the left when the user clicks a link, and everything else should be hidden. When the layer is closed, th ...

Combining 2 rows in an HTML table: A step-by-step guide

Can anyone help me figure out how to merge the first row and second row of a table in HTML? I have already merged two rows, but I am having trouble merging the first and second rows together. This is how I want my rows to be merged: |-------------------- ...

Dealing with dynamic width and text-overflow within non-overflowing <div> elements

I'm experimenting with a style that gradually expands a border up to 300px, and then uses text-overflow: ellipses when the limit is reached. If you're interested in seeing what I'm working on, feel free to click here to visit a JSFIDDLE demo ...

The Vue.js v-on:mouseover function is not functioning properly in displaying the menu

When I hover over a LI tag, I want to display a menu. I have successfully implemented it using a simple variable with the following code: @mouseover="hoverFormsControls=true" @mouseleave="hoverFormsControls=false" However, when I attempted to use an arr ...

Do not break the line following a hyphen

Is there a solution to avoid line breaks after hyphens - on a case-by-case basis that is universally compatible with all browsers? For example: Consider this text: 3-3/8", which in HTML appears as: 3-3/8&rdquo; The issue arises near the end of a lin ...

Adjusting font size, contrast, brightness, and sound levels on a website with the help of jQuery

My client has a new requirement: adding functionality to increase font size, adjust contrast/brightness, and control sound on his website. When clicking on any of the control images, a slider should appear for the user to make adjustments accordingly. Ho ...

Capture an image of the video frame every second

Have you ever noticed the cool feature on YouTube where you can easily 'scrub' through video and see a thumbnail view at each second? https://i.sstatic.net/Yi8He.png I'm curious - how is this achieved? Does the server have to send over eac ...

PHP: The constant ENT_HTML5 is not defined and has been assumed as 'ENT_HTML5'

I encountered the following error message: Use of undefined constant ENT_HTML5 - assumed 'ENT_HTML5' in /blahblahpath/application/models/Post.php on line 12 This error occurred in a basic model that handles some POST input in a forum applicatio ...

Having trouble aligning the image to the center

After researching and trying various solutions suggested for aligning an image, I am still unable to get it to align as desired. Here is the HTML code snippet: <section> <img class="seattle" src="img/Seattle Pier.jpg" alt="Seattle docks"> ...

Transforming Button style in jQuery Mobile version 1.3.0

There are reports of a new function in jQuery Mobile 1.3.0 that allows for dynamically changing button themes using JavaScript: http://jquerymobile.com/blog/2013/02/20/jquery-mobile-1-3-0-released/ However, upon attempting to run the provided code snippe ...

Smooth transitions that will enhance your webpage's SEO rankings

Lately, I have been experimenting with AJAX and absolutely enjoying how it elevates the user experience. One aspect of my (Wordpress) website that I believe could benefit from enhancement is incorporating animated transitions between pages. Nevertheless, ...

Create collapsible horizontal submenus in Bootstrap for mobile devices

I created a modal specifically for mobile users that displays when they access the site. It features various categories and nested menus for easy navigation. <!-- Modal --> <div class="modal fade" id="exampleModalCenter" t ...

Ways to avoid overflow of dynamically added div element?

Currently, I am facing an issue while dynamically appending div elements with the .magnet class to my page. These elements end up overflowing the container boundaries and I am struggling to find a solution for this problem. If anyone could check out my j ...

Guide on creating CSS for webkit scrollbar through the use of Javascript

I have a div named 'dynamic' with text inside, and I am applying styling to it using javascript. var styleElement = document.createElement("style"); styleElement.appendChild(document.createTextNode("#dynamic { color: red; }")); document.getEleme ...

JavaScript: create a button that dynamically changes size and color when scrolling

I have a pulsing button (#scrollarrow) at the bottom of my website that disappears as I start scrolling. The jQuery code responsible for this effect is as follows: $(document).ready(function(){ $(window).scroll(function(){ if ($(thi ...

Placing a Div element outside of a Flexible Grid Layout

I am currently in the process of developing a responsive website using HTML5, CSS3, jQuery, and Media Queries. One challenge I am facing involves a page containing a gallery of images within a 16-column grid that adjusts nicely for various screen sizes, i ...

Struggling with integrating vue pagination

I am looking to add pagination functionality to my website and stumbled upon a visually appealing example that is compatible with Vue. However, despite my lack of experience with Vue, I am struggling to get the demo to work properly. The pagination compon ...

When two rectangles are created at the same coordinates (x, y) in SVG, it results in an unexpected border appearing

.rect-x { fill: red; } .rect-y { fill: pink; } <svg viewBox="0 0 1024 768"> <rect class="rect-x" x="0" y="0" width="100" height="100"></rect> <rect class="rect-y" x="0" y="0" width="100" height="100"></rect> </svg& ...

Django works perfectly on local host, but unfortunately, hosting servers are not cooperating

Programming is a new skill for me and I recently created a weather app using Django. The app functions perfectly when I run it locally with the server, but I've encountered difficulties when trying to host it on various platforms. Here is the link to ...

PHP: Saving data to disk access

I am currently working on developing a notepad application that allows users to save files by clicking a "save" button, but I am encountering an error. I suspect that the script (or Apache) does not have the necessary permissions to write to the disk, but ...