The ellipsis feature is malfunctioning when applied to labels

Hey there, I'm looking to style my label with an ellipsis effect that is inside a UL element. I have tried adding max width and min width for the UL, along with ellipsis and overflow hidden for the label. However, this causes the label content to be pushed down. Inside the label, I have both an input and text. Here is the code snippet I've been working on:

ul{
    min-width: 200px;
    margin: 0;
    border-radius: 0;
    max-height: 270px;
    max-width: 200px;
    background:red;
}
label{
   overflow: hidden;
    text-overflow:                    ellipsis;
    white-space: nowrap;
    display:block;
}
<html>
    <ul class="dropdown-menu main ">
<li>
<a href="#">Select All</a>
</li>
<li>
<a href="#">Select None</a>
</li>
<li>
<label>my numbers</label>
</li>
<div ">
<li>
  <input  type="checkbox">
  <label class="">one</label>
</li>
   <li>
  <input  type="checkbox">
  <label class="">oneeeeeeeeeeeeeeeeee</label>
</li>
   <li>
  <input  type="checkbox">
  <label class="">twoooooooooooooooooooo</label>
</li>

</div>

<button >cancel</button>
<button >Apply</button>
    </ul>
</html>

If anyone can provide assistance, it would be greatly appreciated. Thank you!

Answer №1

Relocate the ellipsis rules to the li element and configure the label elements to have a display:inline; property.

ul {
  min-width: 200px;
  margin: 0;
  border-radius: 0;
  max-height: 270px;
  max-width: 200px;
  background: red;
}

label {
 
  display: inline;
}

li {
 overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
<html>
<ul class="dropdown-menu main ">
  <li>
    <a href="#">Select All</a>
  </li>
  <li>
    <a href="#">Select None</a>
  </li>
  <li>
    <label>my numbers</label>
  </li>
  <div>
    <li>
      <input type="checkbox">
      <label class="">one</label>
    </li>
    <li>
      <input type="checkbox">
      <label class="">oneeeeeeeeeeeeeeeeee</label>
    </li>
    <li>
      <input type="checkbox">
      <label class="">twoooooooooooo0000oooooooo</label>
    </li>

  </div>

  <button>cancel</button>
  <button>Apply</button>
</ul>

</html>

Please be cautious as using <div "> may lead to syntax errors, which could go unnoticed if you have color blindness. https://i.sstatic.net/NXqmz.png

Answer №2

There seems to be an issue with your HTML code.

ul{
    min-width: 200px;
    margin: 0;
    border-radius: 0;
    max-height: 270px;
    max-width: 200px;
    background:red;
}
label{
   overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
    display:block;
}
<html>
 <ul class="dropdown-menu main ">
              <li>
                <a href="#">Select All</a>
              </li>
              <li>
                <a href="#">Select None</a>
              </li>
              <li>
                <label>my numbers</label>
              </li>
              <div>
                <li>
                  <input  type="checkbox">
                  <label class="">onefdgdsfandsfñjndjñkadsnfkjsadoyhfgbohdsaingdsag</label>
                </li>
                                   <li>
                  <input  type="checkbox">
                  <label class="">oneeeeeeeeeeeeeeeeeefdsafndsaifndaipfjndsapfijondsaf</label>
                </li>
                                   <li>
                  <input  type="checkbox">
                  <label class="">twoooooooooooooooooooooooooooooooooooadsfndsapifdsaofndsam0finkdsaf</label>
                </li>
                
              </div>
              
              <button >cancel</button>
              <button >Apply</button>
            </ul>
</html>

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

Is it possible to isolate specific HTML elements within a designated area?

Is it possible to identify which elements are located within a specific rectangular region on a web page identified by a URL? UPDATE: The default settings for screen resolution, font size, etc. can all be adjusted to reasonable values. ...

Mastering Instagram Automation: Techniques for Navigating the Lightbox with Selenium

I am in the process of developing a Python script that assists users in Instagram engagement groups by efficiently liking everyone's photo during each round. I am facing an issue where Selenium is unable to click on the first photo when I reach a user ...

Sliding in the wrong direction on Bootstrap 5.2 carousel

I'm currently working on a carousel project. However, I encountered an issue where the images slide down initially and then jump up to the correct level as depicted in the image below. I've tried adjusting the height, width, and auto settings to ...

Is it possible to utilize the text-search feature in browsers for an HTML5 application?

Our team is currently developing a new feature for our HTML5 app that mimics the 'text search' function found in web browsers, which highlights specific texts. We're considering whether we can utilize this existing feature in browsers by ca ...

How to create a slideToggle effect for nested ul and li elements

Initially, everything was working fine until I put it through the W3C validator. After fixing the errors, now it's not functioning as expected. I have created a jsfiddle The setup involves nested ul elements being used as dropdowns, with headers tha ...

Include a picture and a division element within the dropdown element

I've encountered a few challenges while trying to personalize a profile dropdown component using Semantic and React. First, I am facing an issue where my application crashes when I attempt to place a div inside the Dropdown.Menu with the error message ...

What is the best way to determine when to execute a specific block of code in JavaScript?

I'm working on a backbone project where I need to show an Edge HTML5 animation when the page is loaded, followed by triggering a Gumby modal click event. However, I want to ensure that the modal click event is executed only after the animation has fin ...

Tips for utilizing a PNG image as a cursor in Vue

I am attempting to implement an image as a cursor in my Vue app. I have tried the following code: <template> <v-app :style="{ cursor: 'url(' + require('@/assets/images/custom_cursor.png') + ')&apos ...

Troubleshooting Problem with HTML Links in jQuery Accordion

After experimenting with adding a link to the HTML section of the accordion, I discovered that the link appears bold and does not open. I attempted to create a class or ID to fix this issue, but my efforts were unsuccessful. http://jsfiddle.net/q2Gm9/ ...

I attempted to layer multiple images on top of each other, but unfortunately, the background has disappeared

I am attempting to align a series of images together, but I seem to have lost the background in the process. I am using "position:absolute" and while the images stack nicely due to their correct sizes, there seems to be an issue with the backgrounds. My go ...

Enlarge Django thumbnail when hovering over it in Django admin console

Looking to incorporate a CSS hover effect into this Django admin function that shows a thumbnail in the admin area. The goal is to enlarge the image when hovered over. def image_tag(self): if self.image: return mark_safe('<img ...

Discover the row and column of a selected table cell using vanilla JavaScript, no need for jQuery

In my JavaScript code, I am currently working on creating an onclick function that will display the row and column of a specifically clicked cell in a table. I have successfully implemented functionality to return the column number when the cell is click ...

Using jQuery to resize a div element when it is clicked on

I'm currently working on a project where I have a div that displays the user's status, with its width being based on a percentage ranging from 0 to 100. I'd like to add an animation feature where, upon clicking a button, the div's width ...

What is the conventional method for organizing forms in ASP.Net?

Here's my forms layout: <body> <p>Please note that this form is solely for illustrating the Required Field Validator and does not perform any actual function.</p> <form id="frmValidator" method="post" runat=" ...

Create a visual representation by converting it into an HTML table

Check out my JSFiddle here: http://jsfiddle.net/0r16e802/4/ I'm attempting to display an image as an HTML table, but I'm facing two major issues with my algorithm: Only the first image is loaded in the first row and I need to figure out how to ...

Enhancing TYPO3 menu with custom HTML styling using stdWrap.override

Recently, I created a menu using TypoScript where I decided to customize the standard title with my own text: lib.menu = HMENU lib.menu.special = list lib.menu.special.value = 3304, 7753 lib.menu { 1 = TMENU 1 { wrap = <ul class="menu" ...

How can z-index and relative positioning be used to center a button with jQuery and CSS?

One issue I am facing is with a button that is located in the center of another div (container). When the button is clicked, some hidden divs appear within this container. Although they are present but initially set to display: none using CSS, and then sho ...

Creating a border indentation for a table row using the <tr> tag

In my database, there is a table that shows the parent-child relationship. Check out this link for more details The HTML structure of the table is as follows: <table> <tr class="parent_row"> <td >1</td> <td>2</t ...

Steps to record and upload a video directly to the server using getusermedia

For my application, I need the user to record a video and have it saved on the server disk instead of downloading it to the client browser. I am currently using getusermedia for this purpose, with the following code: (function(exports) { exports.URL = exp ...

Utilizing Bootstrap 5 with either a 16 or 24 column grid system minus the need for Sass

I'm looking for assistance in adjusting Bootstrap 5 to have either a 16 or 24 column grid rather than the default 12 columns. I attempted using Bootstrap Customize but found it to be an older version. I want the flexibility to change the grid from 12 ...