Ensure that the width does not decrease

Edited: included fiddle and code snippets

I am facing an issue with the width of columns in my layout. The width of the columns is dynamically calculated based on the content they hold. However, when I filter the results using a search input for a specific column, the width jumps as the children divs get hidden and do not require the width anymore.

Is there a way to prevent this from happening without setting fixed or min-width values? Each column can vary greatly in width and should adjust accordingly.

Check out this JSFiddle link for better understanding!

Here is the HTML structure:

<div id="app">
  <span>Type 'bla' and see how first column shrinks</span><br>
  <input type="text" v-model="searchWord" @input="searchRows">
  <div class="columns">
    <div class="column">
      <div class="row" v-for="(row) in rows1" v-show="row.visible">{{row.value}}</div>
    </div>
    <div class="column">
      <div class="row" v-for="(row) in rows2">{{row}}</div>
    </div>
  </div>
</div>

And here is the CSS styling:

.columns {
  display: flex;
  flex-direction: row;
}

.column {
  display: flex;
  flex-direction: column;
  text-align: left;
  border-right: 1px solid;
  border-top: 1px solid;
  border-left: 1px solid;
}

.row {
  border-bottom: 1px solid;
}

Lastly, the Vue.js logic:

new Vue({
  el: '#app',
  data: {
    searchWord: "",
    rows1: [{
        value: "long long long long long row",
        visible: true
      },
      {
        value: "blablabla",
        visible: true
      }
    ],
    rows2: ["short row", "blabla"],
  },
  methods: {
    searchRows: function() {
      this.rows1.forEach((row) => {
        row.visible = true
        if (!row.value.match(this.searchWord)) {
          row.visible = false
        }
      })
    }
  }
})

Answer №1

Solved the issue by utilizing table tags correctly and applying styles as outlined in this resource 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

Comparing the efficiency of Jquery draggable with thousands of elements versus updating the elements continuously

Currently, I am developing an application that involves dragging an image using Jquery's draggable utility. The image is accompanied by several overlay divs containing various components positioned based on pixel locations, sometimes reaching into the ...

How to utilize the ternary operator efficiently to evaluate multiple conditions in React

Is there a way to change the style based on the route using react router? I want the description route to display in orange when the user is in the description route, white when in the teacher-add-course route, and green for all other routes. However, th ...

Creating a multi-step progress bar in Yii2 that showcases completed steps using jQuery

Is there a way to automatically transition from one state to another once the order status changes in Yii2? var i = 1; $('.progress .circle').removeClass().addClass('circle'); $('.progress .bar').removeClass().addClass(&a ...

The CSS file that is defined first in the node.js HTML is the only one being utilized

Currently, I am incorporating CSS and JS files into my node.js/express application with the help of the ejs templating engine. Interestingly, while the JavaScript files are being successfully implemented, only the first included CSS file seems to be affect ...

Errors with pointer events occurring within nested iframes on Chromium 78

At first glance, it seems like a bug specific to Chromium. I have already reported this issue in a bug report. Since progress is slow on that front, I am posting a question here primarily to see if anyone else has encountered similar or related issues and ...

Using Javascript/JQuery to apply pixel values in CSS styling

Recently, I've come across a discrepancy between two different ways of accessing CSS properties in jQuery: <foo>.css('marginTop') (which I always assumed was the standard notation) and <foo>.css('margin-top') (which ...

How can I fetch a value from a database and set it as the selected option in a

I am facing an issue with the usage of the selectpicker plugin from Bootstrap in order to select multiple items. My requirement is to create a modal for editing where the data is fetched from previous records, particularly an array. I am looking for a way ...

How to handle event methods with Vue

Currently, I am facing a challenge in passing an event downward with a bound change listener to a child input component. Although I am utilizing wrapped input components, my goal is to define methods within the parent component. //App.js: <currency-inp ...

MaterialUI AppBar is missing a crucial element

I recently dived into the world of Material UI for React and it's been a good experience so far. However, I've noticed a white gap in my header that I can't seem to get rid of. https://i.sstatic.net/zAZJu.png Here is the snippet from my in ...

Encountering issues with properly implementing the .replaceWith(jQuery('#content')) function in CodeIgniter

I'm having trouble with using the jQuery function .replaceWith(jQuery('#content') in Codeigniter. While I can successfully replace the "content" part of my html, the page background image is not showing up. Controller: public function inde ...

Animating a CSS overlay

My goal is to design an overlay using the following HTML and CSS code snippets div.relative { position: relative; width: 400px; height: 200px; border: 3px solid #73AD21; } div.absolute { position: absolute; top: 50%; right: 0; width: 20 ...

maintain visibility of website menu while scrolling

I am having trouble getting my drop-down menu to stay fixed at the top of the screen while scrolling down on my website. Despite several attempts, I have not been able to achieve this using the current CSS and menu setup. Can someone please assist me wit ...

Having trouble resolving a setInterval problem with JavaScript?

Yesterday, I learned about the setInterval function which allows me to execute a task or function after a specific amount of time. While I have successfully implemented the interval in my code, it keeps adding new lines with the date each time. What I re ...

Comprehending the principles of Vue components and navigation paths

I have embarked on the journey of mastering the art of website development, utilizing a Vue frontend in conjunction with an Express REST backend. One of the new routes I created looks like this: /path/to/vue-client/routes/index.js import Vue from ' ...

What is the best method for eliminating buttons and text in a row using CSS?

I faced an issue when trying to create a row, so I improvised with the following setup. However, I actually need a proper row layout for both the Google button and telephone number button. Here are my CSS snippets: .google-button { color: white; borde ...

Tips for refreshing a page in Vue.js

I am facing an issue with updating a table on my page after deleting a row. Each row in the table has a delete button and I have tried using window.location.reload() but it didn't work. </va-card> <br/> <va-card > ...

Displaying a box with a question mark using Glyphicon and Font Awesome icons

I'm having a problem with my website not displaying the Glyphicons or Font Awesome Icons. When I enter the code, it shows up like this: http://prntscr.com/8qwwmd. This is the first time I've encountered this issue and it's only affecting som ...

The Mystery of jQuery Isotope Plugin: Why Can't I Add "display:none" Inline?

I'm currently in the process of integrating Isotope into my latest Wordpress theme. However, I've encountered an issue where it's not appearing on the page due to some external factor adding an inline style (display:none) to the main isotope ...

Harness the power of a dynamic v-for loop within VueJS to bring

I have two yml files (one in Fr and the other in Nl), each containing a line called "language" with the respective language. Assume that I receive a list of words in both languages from the backend, which I save as listFr & listNl. My goal is to crea ...

assigning attributes to web addresses

Is there a way to set a style property for webpages by targeting addresses that contain /index.php/projecten/ instead of specifying each complete address in the code? Currently, I am using the following code: <ul class="subnavlist" style="display: &l ...