Troublesome sizing and text wrap problem found in <ul> elements

Update: Successfully resolved the initial issue, now focusing on fixing the second part.

Take a look at this demo app I am developing. I am working on adding a feature that allows users to create subtasks for each todo item, which will appear when the task is clicked on. However, I encountered an issue when a task has a lengthy description like:

<li>veryveryverylongstringveryveryverylongstringveryveryverylongstringveryve...

This causes the list to overflow and expand the table width (try clicking on any task in the fiddle link above to see the problem). This is the main issue I need help resolving. I have attempted using CSS properties like word-wrap: break-word and tried suggestions from other stackoverflow posts with no success on the following div element:

<div class="container" ng-show="thisTodo.showSubtask" style="background-color:red">

This brings me to problem 1: How can I ensure that list elements wrap properly without altering the original table size?

The second issue involves:

<li>
<label>
<input type="checkbox">
</label>
<input type="form-control">
<button class="btn btn-primary btn-sm"><i class="glyphicon glyphicon-plus"></i></button>
</li>

This snippet does not occupy the entire width of the cell it's placed in. I'm uncertain about the best approach to address this concern.

I welcome any guidance or advice on these matters.

Thank you very much.

Answer №1

.line-item{
overflow-wrap: break-word;  
}

It can be useful to split your words to fit the width of the container.

Answer №2

To handle long text, consider using word-wrap: break-word and setting a max-width for the <li> element. For full width filling within a container, check out Bootstrap's Grid System at http://getbootstrap.com/css/#grid. You can utilize a <div class="row"> with 3 columns as follows:

<div class="col-md-3">{content}</div>

<div class="col-md-6">{content}</div>

<div class="col-md-3">{content}</div>

For further details, visit: https://getbootstrap.com/examples/grid/

Answer №3

Issue 1:
Have you attempted this yet?

overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;

Try this out, maybe you can gain some insights from it even if it's not flawless.

Problem 2:
The last column's td width is too wide, perhaps this solution might be helpful?

.table td:last-child, .table td:first-child {
    width: 1px;
}
// or more specific (less hacky)
.table td:first-child {
    width: 30px;
}
.table td:last-child {
    width: 52px;
}

Third issue (extra credit):
Too few/many columns in your table above/below the main content can lead to unexpected behavior. Having 3x TDs also requires 3x THs.

<thead>
    <tr>
        <th><i class="glyphicon glyphicon-check"></i></th>
        <th>Task</th>
        <th></th>
    </tr>
</thead>

Introducing a third column in the header fixed an issue with the top border having a 1-pixel error.

Check out the jsfiddle demo

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

Running Angular JS code after completion of jQuery.ajax operation

I am facing a challenge in updating an Angular scope with data retrieved from a jQuery ajax call. My main reason for wanting to make the Ajax call from outside of Angular is twofold: a) I need the call to execute quickly, even before the document is fully ...

Unable to adjust opacity level with Bootstrap slider

I am encountering issues with my slider as it is not changing the value properly. Every time I try, I receive an error message in the console saying "Uncaught TypeError: Cannot set property 'opacity' of undefined". What I want to achieve is to a ...

Having trouble getting Lodash filter to work with multiple conditions?

Are you facing issues with using the lodash library to filter an array of objects? If the filter is returning the same value that was passed into it, there might be something wrong in your implementation. Here's the function I am using to transform da ...

Error validation for jQuery div dropdown

Can jQuery validation be used to set the required attribute on a Bootstrap styled div dropdown instead of an option/select tag? The tags cannot be changed on this page, and there are multiple div dropdowns. <div class="btn-group"> <button typ ...

Ways to implement a custom scrollbar across an entire webpage:

I am trying to implement the Jquery custom content scroller on my webpage to replace the default scrollbar. However, I am facing difficulties in getting it to work properly. You can view my code on Codepen. Although the plugin works fine with smaller blo ...

serving files using express.static

I have set up express.static to serve multiple static files: app.use("/assets", express.static(process.cwd() + "/build/assets")); Most of the time, it works as expected. However, in certain cases (especially when downloading many files at once), some fil ...

Encountering an issue with JQuery when attempting to create a double dropdown SelectList. Upon submitting the POST request, the output received is always

Two dropdownlists have been created, where one acts as a filter for the other. When selecting a customer from the dropdown Customer, only a limited set of ClientUsers is displayed in the dropdown ClientUser. This functionality is achieved using a jQuery fu ...

Trigger IntersectionObserver refresh

Can an IntersectionObserver instance be updated or triggered to run manually? By default, the callback is executed when the viewport changes, but I am interested in activating it based on other events such as element changes. For example: During initiali ...

Social media icons failing to adhere to inline block formatting

Three social icons were designed to be displayed in a row (check out the working JSFiddle - here). Despite this, when implemented on my Wordpress blog, they are not positioned side by side but rather stacked on top of each other as seen here - . Is there ...

Header with absolute positioning doesn't play nice when nudged in Chrome

Take a look at the HTML page on this JSFiddle link: http://jsfiddle.net/rb8rs70w/2/ The page features a "sticky" header created using CSS with the property position: absolute. ... <body class="body-menu-push"> <header role="banner"> ...

"Utilize the forEach method to iterate through an array and

Is there a way to output only the values of arrise.tester2? Maybe using forEach or JSON.stringify? Here is the code snippet: var arrise = [{"tester1":"testo","tester2":["testi1","testi2"]},{"tester1":"testc","tester2":["test1","test2"]},{"tester1": ...

The array is remaining empty

When I need to loop through a JSON file, I typically use the following code snippet: var list = new Array(); $.getJSON("json.js", function (data) { $.each(data, function () { $.each(this, function (k, v) { var list = new Array(); ...

"Upon submission, the form will display results within the designated div container

After struggling for a few days and editing some codes, I finally managed to send my form data to process.php without reloading the page. I am using a bootstrap layout and want to avoid the page reload or redirection to process.php. The HTML form works pe ...

Dynamic Select Option housing Bootstrap Popover

I am attempting to create a popover that generates dynamic content and reacts when an option is selected. On my page, I have a select element and one of the options should trigger a popover containing a form with 'Accept' and 'Cancel' ...

Scrapy and xpath not functional - solely relying on css for operation

Attempting to scrape data from this website: After retrieving all elements using the following code: products = response.xpath("//ul[@class='products']//ancestor::li") I attempted to extract prices for all elements in the scrapy shell ...

The appearance of random instances of the letter "L" within text on Internet Explorer 8

Help needed! I'm encountering an issue where mysterious "L" characters are appearing in IE 8. The problem is specifically occurring in the Healthcare Professionals section and the bottom two blocks of the page. Has anyone else experienced this or have ...

Saving user input as a local variable to be utilized on a different web page

I am attempting to capture a user input from a form and then utilize that variable on a separate page. This process should be straightforward, but I am not receiving any results and I am unsure of the reason why. Here is the code on the first page: <di ...

Problem with memory management in ThreeJS

After developing a ThreeJS app using the canvas renderer to meet project requirements, I encountered a memory and garbage collection issue. As part of the application logic, numerous meshes are created for animations on sections of a flat 2D donut or ring ...

Sending back the requested information in C to the ajax (jquery) CGI

After fetching specific data using C in my jQuery, how can I appropriately transfer the data to C? function Run() { $.ajaxSetup({ cache: false }); var obj = {"method":"pref-get","arguments":{"infos":["sys_info"]}}; alert("Post Json:" + JSO ...

Passing Parameters to Razor Pages Controller

Within my controller, there exists a function as follows: public ActionResult AddSubSub(int? idOfSubsub) { return RedirectToAction("Index", new { searchword = "" }); } I am able to invoke this function without providing any parameter. I attempted the ...