utilizing ellipses within a data chart

I am facing a dilemma with conflicting arguments while working on a table that is using an ellipsis. The situation involves a table with a tr tag and 2 td's. I require the first td to be the width of the text ( border-collapse: collapse ) which is achievable, HOWEVER, I also need the width of the table to be 100% so that I can use the ellipsis in the 2nd td. So far, I have not been able to figure out how to border-collapse the first td and implement an ellipsis on the second one.

http://jsfiddle.net/epywtvjf/2/

   <table>
     <tr>
        <td>This is the first div.
        </td>
        <td>This is the second div. This is the second div.This is the second div. This is the second div. This is the second div.
        </td>
      </tr>
      <tr>
        <td>This is the first div.
        </td>
        <td>This is the second div. This is the second div.This is the second div. This is the second div. This is the second div.
        </td>
      </tr>
      <tr>
        <td>This is the first div.
        </td>
        <td>This is the second div. This is the second div.This is the second div. This is the second div. This is the second div.
        </td>
      </tr>
   </table>

table{
   table-layout: fixed;
   width: 100%;
   border-collapse: collapse;
}

table td{
  white-space: nowrap;
  border: none;
  line-height:unset;
  padding: 0px;
  text-align: left;
}

Answer №1

If you're looking to improve the layout of your table rows, consider adding display flex to the tr element in your CSS code. Here's an example that worked for me:

table {
       table-layout: fixed;
       border-collapse: collapse;
       width:100%;
}
tr{
  display: flex; 
}
td{
      white-space: nowrap;
      border: none;
      padding: 0px;
      text-align: left;
      border-collapse: collapse;
}
#td2 {
      overflow:hidden;
      text-overflow: ellipsis;
}

Check out this JSFiddle link for a live demo.

Answer №2

To apply specific CSS styles to individual table cells, you can assign a class to each cell in the HTML code and then target that class using the .class selector in your CSS stylesheet.

<table>
         <tr>
            <td class="col1">This is the first column.
            </td>
            <td class="col2">This is the second column. This is the second column. This is the second column. This is the second column. This is the second column.
            
            </td>
          </tr>
</table>


table {
       table-layout: fixed;
       border-collapse: collapse;

       width: 100%;
}
td{
      white-space: nowrap;
      border: none;
      padding: 0px;
      text-align: left;
      
      border-collapse: collapse;
      overflow: hidden;
}
.col2 {
      text-overflow: ellipsis;
}

http://jsfiddle.net/krewn/qcypz5xk/

Answer №3

Could adjusting the table-layout to fixed and adding overflow:hidden help resolve your problem? Find additional insights here

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

Dealing with problem of highlighting links in Android WebView

I am currently using an html app that is being loaded in a WebView. My goal is to prevent a specific link from loading when clicked by using shouldOverrideUrlLoading, where I return true to stop the URL from loading. While this method works well, the link ...

React JS Bootstrap Dropdown Troubleshooting

I'm facing a challenge in my React.js project while trying to implement a filter. The issue is that the list appears when I click on the button, but it doesn't disappear on the second click or if I click outside the list. Initially, I imported t ...

Arrange an item independently of surrounding elements

Is it possible to position an element across two columns, starting in the middle of the second column? The columns are defined by divs. Could this be achieved through z-index positioning? ...

Is there a way to implement a sticky footer on just a single webpage if that's all I need?

On my main page, I have an empty div with only a background image. To prevent it from collapsing, I created a sticky footer using the following code: * { margin:0; padding:0; } html, body, #wrapper{ height: 100%; } body &g ...

Translating JavaScript, HTML, and CSS into a Class diagram

I've been on the hunt for a tool that can assist me in creating a class diagram for my current web development project. Although I have a plugin for Eclipse that works for JavaScript, it lacks the ability to connect elements from HTML and CSS - . I ...

How to style date strings in JavaScript, jQuery, or CSS

Below are dates that need formatting: 7-sep, 14-sep, 21-sep, 28-sep, 5-oct,12-oct, 19-oct,26-oct, 2-nov, 9-nov, 16-nov, 23-nov,30-nov, 7-dec,14-dec, 21-dec,28-dec-2013. Is there a way to tidy them up using JavaScript, jQuery, or CSS? Ideally, I would lik ...

What causes my words to link together, and what is the term for this phenomenon?

Is there a specific term for the way my font is changing automatically? How can I emulate this effect on other text? And how do I remove it if needed? https://i.sstatic.net/yIe2f.png ...

The background image fails to show up on the mobile device display

Currently, I am working on an app with Ionic, but unfortunately, the background image is not showing despite all my efforts. I have gone through various solutions provided in previous questions, but none of them seem to work for me. Here is the CSS I am u ...

Using jQuery to iterate through an array and reverse its order

Is there a way to loop through an array and change the CSS background color chronologically rather than randomly? Additionally, is it possible to reverse through the same array when the back button is clicked? http://jsfiddle.net/qK2Dk/ $('#right&a ...

Accessing the initial element inside a DIV using CSS

In the structure of my code, I have a WYSIWYG editor enclosed in a table within a div element: <div class="mydiv"> <li> <table>My WYSIWYG</table> </li> </table> Within the WYSIWYG editor itself, there a ...

Customizing and adjusting the CSS for all individuals accessing the website

I am in the process of developing a system that will notify users in the office when a specific individual is busy and cannot answer the phone. How can I implement a feature where clicking "engaged" changes the color of the availability box to red on thei ...

an li element is accompanied by a visible box

In my possession is a container: #box1 { height:100px; width:208px; } along with a series <li id="first"><strong>FIRST</strong> </li> <li id="second"><strong>SECOND</strong&g ...

Including metadata in CSS

Is it possible to include metadata with a dynamically created CSS stylesheet that is returned via a <link> tag and read it with JavaScript? (In my scenario, the stylesheet I return consists of multiple smaller ones, and I want my JavaScript code to ...

When hovering over a hyperlink, an image appears but I want to adjust the image's position in relation to each link

I have a unique feature on my website where text hyperlinks reveal small thumbnail images when hovered over. This concept was inspired by an example I found on this page. I initially implemented the code from a post on Stack Overflow titled Display Image O ...

Highcharts' labels on the x-axis do not automatically rotate

One issue I am facing is that my custom x-axis labels on the chart do not rotate upon window resize. I would like to have them rotated when the screen size is less than 399px. Check out the code here $(function () { $('#container').highchart ...

Is Ruby on Rails featured in Designmodo's Startup Framework Kit?

I'm curious if the Startup Framework Kit from Designmodo can be seamlessly incorporated into my Ruby on Rails project. While I've had success integrating their Flat-UI-Pro using a gem, I haven't come across one for the Startup Framework yet. ...

How can I create a drop-down list in Bootstrap 4 input?

Displayed below is an example of a customized button dropdown featuring material icons and the Google Roboto Mono font, ideal for optimal spacing. My inquiry pertains to replicating this behavior with an input field. <!-- Bootstrap CSS --> < ...

Output the name of the file while executing the ant process

Currently, I am utilizing YUI compressor within an ant build process to compress CSS and JavaScript files. I would like the compressor to display the name of each file it is processing as it goes along, so that in case of an error, I can easily pinpoint wh ...

Gaps separating frames

<!Doctype html> <html> <frameset rows="26%,24%,*" noresize border="0" frameborder="no" framespacing="0"> <frame src="frame_a.html" target="_self" name="logo" scrolling="auto"> <frame src="frame_b.html" target="_self" name="menu" ...

Transforming the color of a globe from black to white with gio js

After searching for a solution to change the color of a Three.js globe, I came across a link that didn't work as expected: Change the color of a Three.js globe. My goal is to change the globe color from black to white using . I attempted to use the f ...