Is there a way to restrict the width of a column in a v-data-table?

I'm trying to restrict the width of the Video title column in my headers by using the width: '30%' property. However, despite setting this value, the column width still exceeds the specified percentage. I also attempted using maxWidth: '30%', but unfortunately, it didn't solve the problem. Any suggestions on how I can achieve this?

<v-data-table
  :loading="loading"
  :headers="headers"
  :items="rankedItems"
  :server-items-length="itemCount"
  :disable-sort="true"
  :hide-default-footer="true"
  class="elevation-1"
>
  <template #item.rank="{ item }">
    #{{ item.rank }}
  </template>
  <template #item.user="{ item }">
    <user-chip
      :uid="item.uid"
      :nickname="item.name"
      :avatar-url="item.avatar"
    />
  </template>
  <template #item.value="{ item }">
    {{ $n(item.value) }}
  </template>
  <template #item.gv="{ item }">
    {{ $n(item.gv) }}
  </template>
  <template #item.title="{ item }">
    <v-chip
      :to="{ name: 'videoPlay', params: { id: item.vid } }"
      target="_blank"
      outlined
      label
    >
      {{ item.title }}
    </v-chip>
  </template>
</v-data-table>

computed: {
  headers () {
    return [
      { text: '', value: 'rank', width: '20%' },
      { text: 'Name', value: 'user', width: '30%' },
      { text: 'Video title', value: 'title', width: '30%' },
      { text: 'value', value: 'gv', width: '20%' },
    ]
  },
},

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

Answer №1

If you're looking for a CSS solution, one approach you can take is:

.titleStyle{
    max-width: 30%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

By implementing this code snippet, you'll be able to truncate any text that exceeds the specified maximum width.

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

Incorporate hyperlinks to the right side of the footer section

I want to expand the footer by adding 3 more links to the right side of the logo. These new links should float to the right and always be positioned about 100px from the right edge of the web browser. Check out my JSFiddle for reference: In my attempt at ...

What is the process for inserting a new column into an order list on Opencart?

I'm looking to customize the table in opencart's admin dashboard by adding a new column for 'company name' between 'Customer' and 'Status'. Can anyone guide me on how to achieve this? Which specific file do I need t ...

I am experiencing an issue where the CSS code is not appearing in the Chrome Debugger when I inspect an element

I recently wrote some CSS code to remove default browser styles: /* Box sizing rules */ *, *::before, *::after { box-sizing: border-box; } ​ /* Remove default padding */ ul[class], ol[class] { padding: 0; } ​ /* Remove default margin */ body, h ...

Tips for redirecting a URL link to another link with the identical URI

My program automatically sends users to a webpage where they need to enter their username and password. For example, . I have now developed a new page in asp.net and I would like some code on example.html to change the link to . What I am trying to achi ...

Manipulating CSS content property in React using Material UI

I am trying to set content: "" on my i element: "& i::before": { content: "" }, "& i::after": { content: "" }, However, the style is not being applied and I am seeing an ...

Stop the selection of text within rt tags (furigana)

I love incorporating ruby annotation to include furigana above Japanese characters: <ruby><rb>漢</rb><rt>かん</rt></ruby><ruby><rb>字</rb><rt>じ</rt></ruby> However, when attemp ...

Increasing the size of a card beyond the container using the CSS PRE tag

I am facing an issue with a card on my webpage. It contains a pre tag inside it, which is causing the size of the card to extend beyond its container, resulting in a horizontal scroll bar appearing. How can I make the content within the pre tag scroll hori ...

Slice the towering text in half lengthwise

Ensure that the last line of visible text fits within a 20px padding, or else it should be completely cut off. The challenge lies in the varying text lengths of h3 each time. It's difficult to predict how much needs to be trimmed. Currently, the tex ...

When utilizing jQuery version 1.10.2, the HTML markup shows up prior to the page completing its loading process

I am trying to import one HTML page into another, but when I load or refresh the page, the HTML markup appears before the page fully loads. How can I fix this issue? <head> <script type="text/javascript" src="js/jquery-1.10.2.js" ></scr ...

Is it possible to adjust the scroll top position using inline style in angularJS/CSS?

I am working on storing the scrollTop value of a vertical menu in my controller so that I can set it up each time I return to the page for persistent scrolling. Does anyone know how I can achieve this? This is the code snippet I am currently using: < ...

Ensuring form input validity in real-time using jQuery's keyup event

I've been working on a form where the user can fill in an input and press enter to move to the next field. Although I have managed to get the functionality to show the next div, I am facing issues with validation... // Moving to next div on Enter ...

Submitting a HTML form with a select element that will pass comma-separated values in the URL query

My HTML form includes a dropdown menu. <form method="get"> <select name="category[]" multiple class="form-control"> <option value="1">First Value</option> <option value= ...

Menu disappears below the screen

I am experiencing an issue with my dropdown menu. I am having trouble figuring out how to adjust the position of the dropdown that appears when hovering over the "support" button. I would like to move it slightly to the left as half of it is extending off ...

Embed a data entry point into an existing picture

Looking for assistance inserting a field within an image for users to enter their email. Can someone provide the HTML code for this? Appreciate your help! ...

Create a responsive canvas with custom shapes

After designing a canvas with a gradient-filled circle, I encountered a challenge in making the canvas and the circle responsive to varying screen sizes. Initially, I attempted to use `vh` and `vw` units for the width and height of the canvas. However, ad ...

Webpack and Keycloak Integration: Content blocked because of MIME type ("text/html")

I am currently using VueJS for my frontend with Keycloak handling authentication, along with Webpack to bundle my code. Upon the initial application load, if the user is not authenticated, they are redirected to the Keycloak page. During this process, an ...

Ensure that the second table header remains in a fixed position

One of my tables is scrollable horizontally while the other is not. I'm looking to keep the header of the scrollable table fixed in place. You can take a look at this jsfiddle link for reference. The headers of the second table, which is enclosed i ...

Formatting Text in CSS and HTML

I need help aligning three images horizontally with text underneath, using CSS. Despite trying multiple methods, the images remain vertically aligned and the text does not align properly with the images. #img_cont { display: table; width: 90%; ...

Update the text inside a paragraph using jQuery

When attempting to modify two values within a paragraph using jQuery, I encountered an issue where only one value was successfully updated, leaving the other empty. <div class="container"> <p class="lead custom_bg" id="comment"> updateme! ...

There was an issue while trying to import troika-three-text using the importmap

My goal is to incorporate the troika-three-text into my Three.js script by importing it through HTML, as demonstrated below: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name=&q ...