Issue with Vue2: DIV does not adjust height when using v-for loop

I have a div set up like:

<div class="pt-4">
  <h5>Genres:</h5>
  <div class="inline-block float-left" v-for="(genre, index) in moreData.genres" :key="index">
    <span v-if="index < moreData.genres.length-1" class="mr-2">{{ genre.name }},</span>
    <span v-else>{{ genre.name }}</span>
  </div>
</div>

However, when the content of the v-for statement is rendered, the height of the div remains unchanged. This results in the next element overlapping or floating over it. I tried adding "clear: both" but it doesn't seem like an elegant solution to me.

Answer №1

After experimenting, I discovered that using "display: flex" solved the issue perfectly. It reacts to changes in content and adjusts the dimensions of the DIV accordingly.

Answer №2

It seems like you're facing an issue, but if I understand correctly you may want to try using flexbox

.flex {
  display:flex;
}
<div class="pt-4">
  <h5>Genres:</h5>
  <div class="flex">
    <div class="genre">
      <span class="mr-2">Name,</span>
    </div>
      <div class="genre">
      <span class="mr-2">Name,</span>
    </div>
      <div class="genre">
      <span class="mr-2">Name</span>
    </div>
  </div
</div>

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

What could be causing my jQuery to malfunction after I include the .sqrt() function?

Seeking assistance in creating a grid of divs, I am working on finding the square root of the user's input to determine the height and width required to form a square. The code below is what I currently have: $('#size').click(function(){ $ ...

Customizing CSS for tables within a mat-menu in Angular Material

I am currently developing an application using Angular 7 and Angular Material cdk 6. This is my first experience working with Angular Material and I am facing a challenge in overriding the CSS styles of my columns. Despite several attempts, none of them se ...

Is there a way to ensure that the selected value remains displayed on the select menu even after

Here is a sample code for a status select input: <label>Status:</label> <v-select :options="options" v-model="status" @input="changeValueStatus" /> data() { return { options: [ { label: 'Su ...

What are the best techniques for positioning text next to images in HTML and CSS?

I have attempted to position the text in close proximity to the images as shown in the picture below (to allow for spacing in the middle). As depicted in the image, the "AVENUE FOR GROWTH" and "NETWORKING OPPORTUNITIES" texts are near Man's hand and w ...

Building a Vue application with Node.js, Express, and XAMPP requires careful consideration of the project

I'm looking to develop a CRUD application using technologies such as: - Vue.js - Node & Express - mysqli (xampp) What would be the most effective approach to structuring the project's directory and files tree? Is it preferable to separate into t ...

Displaying divs inline with overlapping child divs

As a beginner in CSS, I tackle the challenges of learning it every day. Despite feeling clumsy and not naturally adept at it, my determination is strong (although sometimes my brain feels like an old computer on the verge of overheating). My current goal i ...

Troubleshooting IE compatibility issues with jQuery .hide() method

I am encountering a curious issue with hiding span elements using CSS (display: none;). Upon page load, I expect the first span element to be displayed, which it does in all browsers except IE7. This anomaly has left me perplexed as there is no unusual cod ...

Display additional information upon hovering without disrupting the neighboring elements

When I hover over a component, I want to display more details and scale it up. However, this action ends up displacing the surrounding components. Take a look at the screenshot for reference: Below is the code snippet where I defined the styling for an MU ...

Is it possible for Skycons to show a duplicate icon?

My current issue involves integrating the JavaScript plugin "Skycons" with the Yahoo weather RSS feed. The problem arises when multiple days have the same weather forecast, as the plugin retrieves icons based on ID rather than class. This prevents me from ...

CSS classes designed to mimic JavaScript object attribute-value pairs

I stumbled upon some interesting css class-value combinations within HTML tags. It seems like a specific JavaScript code is interpreting this, but it's something I haven't encountered before. I came across this on www.woothemes.com/flexslider/ (y ...

Can you explain the functionality of the combination selector "AB," where "A" and "B" represent any selectors?

I've been delving into the concept of the "combination selector" by referring to resources on MDN. This selector involves selecting elements that match both criteria A and B simultaneously when they are placed together. Can someone shed some light on ...

What is the best way to create a CSS class for a list element in React?

I am facing an issue with styling buttons in my UI. These buttons represent different domains and are dynamically generated based on data fetched from the server using the componentDidMount() method. Since I do not know the quantity of buttons at the time ...

Tips on creating animations for a background with a value of 2 using CSS3

Hey everyone, I'm currently working with this CSS style: body { width:100%; height:100%; background:#fff; background-image: url(bg.png), url(clouds.png); background-repeat: repeat; font-family: tahoma; font-size: 14px; ...

Prevent clicking on the <div> element for a duration of 200 milliseconds

I need to make this box move up and down, but prevent users from clicking it rapidly multiple times to watch it go up and down too quickly. How can I add a 200 millisecond delay on the click or disable clicking for that duration? View the jsfiddle example ...

Passing data from one Vue component to another

I am trying to transfer data from one Vue.js component to another. Below is the code I have so far: Can someone please point out where I went wrong? Your help is greatly appreciated! Thank you! ...

What steps can be taken to enlarge the select button within a <select> field?

Is there a way to enlarge the size of the downward-pointing arrow button within a <select> element? Here is an example of what my code looks like: <select> <option>Select City</option> <option>City1</option> <o ...

Reverse animation transition not activating in CSS

In an attempt to create a side navbar using HTML/CSS, I implemented hover animations where hovering over an icon would cause it to double in size and disperse the rest of the items in the navbar. While I successfully achieved this animation with JavaScript ...

How come my flex-box navigation bar is not collapsing as I shrink the browser window size?

I'm currently experimenting with FlexBox to enhance the design of my website, specifically focusing on creating a responsive and collapsible navigation bar for mobile users. I'm encountering issues with the flex commands in the .nbar class not wo ...

Missing ng-required fields not displaying the has-error validation in AngularJS forms

While editing any part of their address, the user should see a red invalid border around each field to indicate that the full form is required. However, for some reason I can't seem to get the 'Address' field to display this border. The set ...

Tips for positioning images in the center of a footer

Hello, I am new to coding and would like some help adjusting the code for this website: The footer section at the bottom of each page features a row of logos. My goal is to make sure that these logo images display properly on mobile devices (without dropp ...