Stop horizontal overflow of content

This unique Vuetify demo on CodePen showcases a two-column layout. The first column contains a <v-list> enclosed in a green <v-alert>. By clicking the "toggle text" button, you can switch the title of the first list item between short and long forms.

However, there is an issue when the text is long - it spills over the boundaries of the <v-alert> and extends into the adjacent column.

https://i.stack.imgur.com/7NDaB.png

To address this problem, I would like to either truncate the overflowing text with ellipsis once it reaches the edge of the green alert, or allow the text to wrap onto multiple lines within the alert box.

I attempted to resolve this by applying the following CSS class to the text, but unfortunately, it did not prevent the overflow:

.prevent-overflow {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

Answer №1

To ensure the text stays within the green container without overflowing, you must specify the overflow property in that element.

          <v-alert text color="success" class="prevent-overflow">

This is where your focus should be. Just to clarify, setting overflow on a container means defining how its contents should behave if they exceed the container's boundaries.

To add ellipsis to the text, you need to do two things. First, include text-over: ellipsis in the title style without word wrapping to prevent the text from dropping down unnecessarily. Second, set the width of the parent div directly containing the text.

For a quick solution in your scenario, you can try something like:

.v-list-item__title {
  width: 20px;
}
.prevent-overflow2 {
  text-overflow: ellipsis;
  
}

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 there a way for me to include a prefix in the path where Vue pulls its component chunks from?

I recently incorporated VueRouter into my project and encountered an issue with the asset URL not being correct. Instead of displaying www.example.com/js/0.main.js The URL it generates is www.example.com/0.main.js Any suggestions on how to include the ...

When using v-for to render an array list fetched from AsyncData, an error is thrown: The virtual DOM tree rendered on the client-side does not match the one

For my application, I am utilizing Nuxt.js. On one of the pages, I am using AsyncData to fetch an array of data objects from my API asynchronously. These data objects are then rendered in my template using v-for. Everything is functioning properly until I ...

Attempting to figure out how to make Bootstrap pagination function properly

I am trying to implement Bootstrap's pagination feature into my project. While I was able to find the HTML code for it on the official Bootstrap page, I am struggling to make the content change dynamically when I move to the next page. Can anyone pro ...

What is the best way to arrange these containers in a horizontal stack?

Check out the code snippet at: https://codepen.io/shayaansiddiqui/pen/YzGzeOj I'm looking to align these boxes horizontally, how can I achieve that? <div> <div class="container"> <img src="#" ...

Is it possible to eliminate the border on an image input button?

Here is the code I've been working on: HTML: <!DOCTYPE html> ... <form> <input type="image" value=" " class="btnimage" /> </form> ... CSS: .btnimage { width: 80px; height: 25px; background:url('C:/Users ...

Issue with Vue3: The imported module is not defined

Update: I recently downgraded vue-cli to version 4.5.19 and now the code is functioning properly. It seems like there might be an issue related to vue-cli or its dependencies. I encountered a problem while working on a simple vue.js project using vue-cli. ...

What triggers a component to be re-rendered?

Struggling to optimize my vuejs app's performance, I can't seem to pinpoint why certain components are constantly re-rendering... Citing the lifecycle hooks, it mentions that a component should indeed re-render when data changes After thoroug ...

ways to add spacing between bootstrap columns

I am currently using Bootstrap 5 and I'm trying to create a row with 6 columns. I have added gutter in the row but for some reason, the spacing between the columns is not being applied. Can anyone help me figure out what I'm doing wrong here? Bel ...

What is the best way to give an element or container a variable width rather than a fixed width?

I have a query regarding positioning and variable width. I've applied the following CSS: *{ border: 1px dotted blue; /*indicator for where every element are positioned or spaced on the page*/ } By adding this to all elements, I can visualize their p ...

Tips on adjusting a position that shifts with changes in window size

Working on a website for my grandpa, I'm planning to include a small biker character that runs across the screen. When hovered over, he stops and advises "wear a helmet." The animation works well, but there's an issue with the positioning when th ...

Vuejs: Limiting the number of items in an li tag to 5

selectPreviousSearch(index) { this.search = this.searchHistory[index]; this.showSearchHistory = false; }, <input class="form-control bg-light-blue" id="SearchText" type="text" v-model="search" @keydown.enter = 'ent ...

What is the best way to make a black background div that perfectly aligns with another div?

When hovering over an image, I want it to fade out to opacity: 0.4, but instead of fading to white, I would like it to fade to black. To achieve this, I decided to change the background color of the body to black so that the fadeout will be towards black. ...

"Unauthenticated: Resolve the 401 error while attempting to subscribe to a private channel using Pusher in a Vue.js

Recently, I set up a Vue3/Laravel application with a live chat feature using Pusher. Initially, everything was working smoothly over the non-private channel chat. However, when attempting to switch to a private channel, things took a weird turn. The pusher ...

Utilizes an external CSS font file for eBay advertisement

After researching numerous answers, I am still unable to identify what I may be doing wrong. I have designed a collection of custom fonts using iconmoon, and after downloading the css and font files, I uploaded them to a directory on my website. I am attem ...

Are there any jQuery plugins available that animate elements as the page is scrolled?

Looking for a library that can create entry animations for elements as the page is scrolled? I previously used the animate it library, which was great - lightweight and easy to use. However, it doesn't seem compatible with the latest jQuery version (3 ...

Vue: navigating to a specific id using scroll is malfunctioning

I have integrated the vueToScroll library to enable scrolling to a dynamically created element with a specific id. <button ref="replyBtn" v-scroll-to="{ el: '#goToReply101', duration: 800, easing: 'easi ...

Header with a stable background image that adjusts responsively

While attempting to convert a PSD to HTML, I encountered a small issue. Please refer to the image below: https://i.sstatic.net/5KoIV.jpg As indicated by the red arrow, there is a blue background image in the header of the template! How can I add this bac ...

Boosting Your Theme - Eliminating Redundant Styles

Currently, I am facing more of a best practice issue rather than a coding one. I am in the process of creating a custom bootstrap theme inspired by https://github.com/HackerThemes/theme-kit. Although I have a functional theme that I am satisfied with, I am ...

Footer void of color

It's puzzling to me where the extra space in my footer is coming from. It seems to be around 20-30px as you can see on the following url: Despite the code in my footer being minimal, with no apparent cause for this additional space below my social ic ...

Are Half of the <a> Links Invisible due to a Possible Issue with Position:Fixed?

There seems to be an issue with some of the links in my navigation bar not working properly. It appears that they are being covered by an iframe element, preventing them from changing color when clicked. Although the iframe element is visibly below the na ...