A div element set to a width of 100% that holds a lengthy text will expand to the entire width of the window,

Check out this simple webpage: https://jsfiddle.net/enxgz2Lm/1/

The webpage is structured with a side menu and a tasks container.

Within the tasks container, there is a row container that includes a checkbox, title on the left, and details on the right.

I'm specifically inquiring about the editable title element.

The title element has the attribute contenteditable="true". I want it to expand to occupy 100% of the available space. If the text exceeds the available space, I would like it to display partially and hide the rest without wrapping into new lines.

In the provided webpage, you can see that I achieved most of what I wanted. However, I'm struggling to maintain the width of the title at 100% of the available space.

Note: If you uncomment the CSS line "width: 470px", you'll get an idea of how the final webpage should look.

Answer №1

To start, include the CSS rule

.side-menu-container { flex: none; }
(or min-with:150px).
Next, replace width: 100%; with .tasks-contianer { flex: auto; } and to avoid stretching, ensure you add
.tasks-contianer { min-width: 0; }
(or overflow: hidden):

* {
  box-sizing: border-box;  
}

body {
  display: flex;
  margin: 0;
  height: 100vh;
}

.side-menu-container {
  width: 150px;
  height: 100%;
  background-color: lightblue;
  padding-left: 15px;
  flex: none;
}

.tasks-contianer {
  padding: 10px;
  background-color: #161A1F;
  flex: auto;
  min-width: 0;
}

.task-container {
  display: flex;
  align-items: center;
  height: 40px;
  background-color: lightgray;
  padding: 0 10px;
}

.checkbox-container {
  width: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.details-container {
  padding-left: 10px;
  color: red;
}

.title-container {
 overflow: hidden;
}

.title-container p {
 white-space: nowrap;
 overflow: hidden;
 text-overflow: ellipsis; /* optional */
}

[contenteditable] {
  outline: 0px solid transparent;
}
<div class="side-menu-container">
  <p>Category1</p>
  <p>Category2</p>
  <p>Category3</p>
</div>
<div class="tasks-contianer">
  <div class="task-container">
    <div class="checkbox-container">
      <input type="checkbox" />
    </div>
    <div class="title-container" contenteditable="true"><p>veryLongTextWithNoSpaceveryLongTextWithNoSpaceveryLongTextWithNoSpaceveryLongTextWithNoSpaceveryLongTextWithNoSpaceveryLongTextWithNoSpaceveryLongTextWithNoSpace
    </p>
    </div>
    <div class="details-container">
      <p>details</p>
    </div>
  </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

What is the best way to arrange a number of inline-block elements with equal size in a vertical alignment?

My goal is to display a set number of items in a container, all with the same fixed size. The challenge arises when the content of each item varies in length, causing misalignment vertically: .child { display: inline-block; background: #bbbbbb; marg ...

Tips for displaying a loading indicator above a form

I've been struggling to figure out how to display a loading indicator on top of my form without messing up the styling... My goal is to show the loading indicator when any action, like deleting an item or changing quantity, is triggered in React.js + ...

Steps for generating an HTML button when an Angular function evaluates to true

I am working on a table in HTML that uses ng-repeat to display data. Here is the code snippet for this table: <tbody> <tr dir-paginate="x in serverData | filter:filterData | filter:filterData | itemsPerPage: itemPerPageValue | order ...

Deciding between Document.createElement() and Document.createTextNode() in Javascript

I'm currently exploring the distinctions between these two code snippets: // first one var h1 = document.createElement('h1'); var t = document.createTextNode('hello'); h1.appendChild(t); document.body.appendChild(h1); // second o ...

The footer navigation in CSS shifts position when it is hovered over

My attempt to add a <nav> at the footer was unsuccessful. The navigation bar in this fiddle is completely wrong as the entire nav moves when hovered, even though I did not include any animations. I want the items in the <nav> to stay fixed. ...

Tips for preventing page breaks (when printing or saving as a PDF) in lengthy HTML tables

Here is the link to a single HTML file (including style and scripts): FQ.html The problem I'm facing can be seen in this image: I've tried several solutions, the latest of which involves the following CSS... @media print{ @page { size:10 ...

How do I use jQuery to animate a height increase where the added height is applied to the top of the element?

I am facing a simple issue that I need help resolving. The problem involves hidden content that, once expanded, needs to have a height of 99px. When collapsed, the container holding this content section#newsletter is set to be 65px in height. If you want ...

Ways to categorize items using JQuery based on their hierarchical structure

I am looking to organize the following HTML content: <h2>State the Issue  </h2> <h3>Provide information about your objective</h3> <h3>Share any error messages received</h3> <h2>Outline Your Attempts  ...

Unable to view numbers on iPhone or ios device

I am facing an issue with displaying a phone number in the contact section on my website. The number shows up on desktop but not on my iPhone, even when I resize the screen to be smaller than my phone's display size. This issue has been tested on both ...

The clash of interests between jQuery and Bootstrap

I'm facing a problem with conflicting jQuery and Bootstrap files in my header.php code. Whenever I include the jQuery file before the bootstrap.js file, it causes issues with the tabs on my website where clicking on them does not navigate me to the co ...

How can I delete a hyperlink on a number from my iPhone or iPad?

Is there a way to prevent certain sets of numbers from being linked, like phone numbers do on iPhones? <h2>Table</h2> <table class="table table-sm table-striped table-hover"> <caption class="sr-only">Search Results</caption> ...

Retrieve the current height of the iFrame and then set that height to the parent div

Within a div, I have an iFrame that needs to have an absolute position for some reason. The issue is that when the iFrame's position is set to absolute, its content overlaps with the content below it. Is there a way to automatically adjust the height ...

How to harness the power of loops in JavaScript

Having trouble getting this code to repeat a CSS transition properly. for (var i=0 ; i<4 ; i++){ setTimeout(function() { $('#top-left').css('margin', '45px 0 0 45px'); $('#top-mid' ...

Challenges in using HAML5 Canvas for mathematical applications

Hey there! I'm currently working on utilizing the canvas element to form various shapes, but I've encountered a few challenges when it comes to the mathematical aspect. Issue 1: I need to calculate an angle that is relative to the preceding line ...

Having difficulty converting the string data to HTML using JavaScript in a Node.js Express application

In my app.js file, I will be sending data to an EJS file. app.get('/', function (req, res){ Blog.find({}, function(err, fountItems){ Blog.insertMany(defaultBlog, function(err){ }) } res.render( ...

Is it possible for a website to instruct a user's browser to save the entire page locally?

Is it possible for a (single-page) website to instruct a user's browser to save the entire page locally? To provide some background: I am running a website on a server that bills based on bandwidth usage. Since the content of the site remains mostly ...

I am encountering issues with my XPath in certain scenarios

When attempting to do an assertion with the total of a dynamic table, I am encountering difficulties writing XPath that works for all scenarios. The issue arises because the table sometimes contains only 1 image and other times it may contain 5 images. In ...

Utilizing Ruby interpolation to dynamically select elements in Capybara's CSS selectors

Having trouble with invalid selector errors when attempting to locate an element using capybara This method is successful: page.find("#widget_amount_Standard") But I encounter issues when trying any of the following: credit_type = "Standard" page.find( ...

AngularJS - displaying a notification when the array length is empty and customizing the visibility to conceal the default action

I've been working on an Angular project where I display a loading circle that disappears once the content is loaded. This circle is simply a CSS class that I call from my HTML only when the page first loads, like this: Actually, the circle consists o ...

What is the difference in speed between drawing on a transparent canvas and determining if a point is transparent compared to determining if a point is within a complex polygon?

I'm curious if anyone has done research on adding event support to a game engine. Specifically, I am working on incorporating pixel-perfect hover over 2D object event support into my own game engine. I am exploring different ways of achieving this eff ...