Creating a table with adjustable row heights is a great way to enhance the user

Can the height of an HTML table row be adjusted dynamically by dragging and dropping, similar to how it's done in this demo (https://reactdatagrid.io/docs/row-resize), but for free?

Answer №1

if you prefer a demonstration using HTML, CSS, and vanilla JavaScript (without any libraries), here is an example:

as shown in the GIF, the size adjusts automatically

https://i.sstatic.net/L3Eca.gif

This example utilizes the contentEditable API available at https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content

let th = document.querySelectorAll("th");
let td = document.querySelectorAll("td");

[th, td].forEach((elAll) => {
  elAll.forEach((el) => {
    el.contentEditable = "true";
  });
});
table {
  border-spacing: 0;
}

th,
td {
  border: 1px solid black;
  padding: 0.5rem;
}
<table>
  <tr>
    <!-- contentEditable attribute will be added here
         <th contenteditable>your content</th>
      -->
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>StackOverFlow</td>
    <td>myName</td>
    <td>Italy</td>
  </tr>
  <tr>
    <td>Facebook</td>
    <td>my second Name</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Google</td>
    <td>my third Name</td>
    <td>France</td>
  </tr>
  <tr>
    <td>Microsoft</td>
    <td>my fourth Name</td>
    <td>America</td>
  </tr>
</table>

The output will resemble something like this: https://i.sstatic.net/lWOla.png


However, if this appears too challenging,

a simpler solution can involve utilizing an online open source library that offers more ease of use and additional functionalities.

You can conduct some research on Google to find one:

https://i.sstatic.net/HWajm.png

All the technical aspects are handled by another developer, your role is to simply import the library, review the documentation, and begin building

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

The SeekTo function in react-player is not working as expected

I've been encountering some difficulties while using the seekTo function with react-player in my next.js site. Whenever I attempt to use it, an error pops up saying: "playerRef.seekTo is not a function." I also tried using "playerRef.current.seekTo(p ...

The counter variable does not function properly within a setInterval function

I have encountered an issue with my scroll-counter variable inside the setInterval function. It increments by 1 each time the setInterval function runs, which is supposed to happen 20 times before stopping. However, I noticed that the value of this variabl ...

Request to api.upcitemdb.com endpoint encountering CORS issue

This code may seem simple, but for some reason, it's not working as expected. What I'm trying to achieve is to call the GET API at: I want to make this API call using either JavaScript or jQuery. I've attempted various approaches, but none ...

Is it advisable to utilize CSS3 media queries to serve varied image sizes for retina display devices?

Although many questions similar to mine have been asked before, I believe my situation is slightly different. I have recently created a mobile app using JQM + Cordova/PhoneGap. In the beginning, I utilized large images aimed at retina display devices and ...

Preventing duplicate Google indexing with .htaccess

I have a website that utilizes a RewriteRule in the root directory to direct queries in this format: http://domain.com/foo/parameter to http://domain.com/index.php?args=parameter Visitors only see the clean URL and everything works smoothly. However, ...

Update a script that handles input float labels to support textarea elements as well

I am looking to modify a float label script that currently works for input boxes in order to make it work for textareas. I attempted to add $fields.on("textarea", floatLabel) to the script but it did not produce the desired result. Any suggestions or assis ...

What is the best way to set a value for a specific cell in a table layout using react js?

I'm currently working on creating a table view in React JS that displays data from January to December, sourced from JSON. I've managed to fetch and assign the data to the table, but I'm facing an issue where the values are repeating and I c ...

Issue with displaying the Bootstrap paginator stylingSomething seems to be

Currently, I am working on a PHP project that involves creating a table with Bootstrap styling. To achieve this, I referred to a tutorial which guided me through the process. After linking the necessary Bootstrap CSS file using the provided code snippet, ...

Automatically adjust height directive to fill up the remaining space

Is there a way to dynamically adjust the height of an element to fill the remaining space within its container? In my current layout, I have a fixed-height header (or menu) in pixels, a content area that may overflow the window height and require scroll b ...

Intrigued by the connection between background and calc()?

Hello everyone! I'm currently involved in a project and have a quick question regarding the calc function. As we all know, it functions perfectly on all browsers... ========== great! ============= background-color:#dfdfdf; background-image:url(..) ...

How to style text alignment and create a toggle button using HTML and CSS

My attempt at creating a custom toggle button using an HTML input checkbox and custom CSS has resulted in a misalignment between the text and the toggle button itself. Despite my efforts to adjust margins, padding, and heights, I have been unable to resolv ...

Begin counting when a particular div element is visible on the screen

I have a plugins.init.js file that contains a try-catch block which runs on page load. I am looking for a way to execute this code only once when the div with the class counter-value comes into view. Is there a method to achieve this? try { const count ...

Learn the process of importing data into an HTML list using Flask

Looking to transfer data from a Python variable to an HTML list? Here's a snippet of HTML code that you can test out: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8> <title>Panel</title> & ...

When integrating external HTML into an Angular 2 component, relative references may become invalid and fail to

My server hosts basic HTML content that includes an image with a relative file location. While this displays correctly in a browser, loading the content using Angular causes issues with resolving the relative path locally. I have tried following suggestio ...

Limit Content to be contained within a Bootstrap Container/Div

How can I shrink the content inside a container without distorting images? When the screen size decreases, all the images and content inside start to lose their alignment and sizes begin to change. I am aware that this may make the content harder to see. ...

The behavior of Mozilla in handling JQuery attr() function may result in variations in design elements such as font-family or font-size

I'm currently working on the login form. Below is my view in CodeIgnitor: <div id="login-form"> <?php echo heading('Login', 2); echo form_open('login/login_user'); echo form_input('email', set_value ...

What causes the input to be rendered as read-only when using the value attribute and as read-write when using the defaultValue attribute?

Within my shopping cart, the quantity of items added dynamically increases by +1 each time the same item is added. Additionally, users can manually adjust the quantity of an item within the cart to their preference. I encountered a dilemma with using the ...

Make sure that the input field and label are aligned side by side in the

Is there a way to arrange the following HTML in the specified layout? <div> <div> <label>Counterparty</label> <input id="paymentsApp-inpt-cpty" ng-model="selectedPaymentCopy.counterparty" ng-required="true" ...

Exploring the dynamic world of Angular2 animations paired with the

In my layout, I have a row with three columns and two buttons to toggle the visibility of the side panels: col-md-3 col-md-7 col-md-2 ------------------------------------ | | | | | left | middle panel | | ...

How does Firefox still autocomplete even with a different input label?

How does Firefox decide where to autofill passwords and usernames? I've noticed that even after changing the name, id, title, or class of an input element, Firefox still automatically fills it with my password or email address. ...