Spread out the CSS grid dimensions to the descendants for the vuetify v-card image

I'm facing an issue with arranging vuetify cards with images in a CSS grid. The problem is that the grid size is not being recognized by the v-card's v-img because it's a grandchild element. How can I pass down the grid size to the v-img?

My goal is to have the images fill out the card, similar to how it looks in the flex-box version (see here)

I am aiming for a responsive design where the image automatically resizes based on the window size.

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

new Vue({
  el: "#app",
  vuetify: new Vuetify(),
  data: () => ({})
});
.grid {
  display: grid;
  height: calc(100vh - 64px - 60px);
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
}

.grandchild {}
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c5b3b0a085f7ebf3ebf4f4">[email protected]</a>/dist/vue.js"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6c1a190918050a152c5e425e425e5a">[email protected]</a>/dist/vuetify.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="acdad9c9d8c5cad5ec9e829e829e9a">[email protected]</a>/dist/vuetify.min.css" />

<div id="app">
  <v-app id="inspire">
    <v-app-bar app fixed dark>
      <v-toolbar-title>Toolbar</v-toolbar-title>
    </v-app-bar>
    <v-content>
      <v-container>
        <div class="grid">
          <v-card v-for="n in 4" :key="n">
            <v-img height="100%" width="100%" class="grandchild" src="https://cdn.vuetifyjs.com/images/cards/docks.jpg">
            </v-img>

            <v-card-subtitle>Number {{ n }}</v-card-subtitle>
          </v-card>

        </div>
      </v-container>
    </v-content>
    <v-footer app dark>
      <span>Footer</span>
    </v-footer>
  </v-app>
</div>

Answer №1

The issue lies in your layout using 1fr. Consider replacing it with minmax(0, 1fr):

.grid {
  display: grid;
  height: calc(100vh - 64px - 60px);
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

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

Create a CSS border that resembles the one used in Google's signup form

lies a curious inquiry: what unique border style is in play here? It rests slightly raised against the backdrop, creating an intriguing visual effect. After combing through various sources online, the answer still eludes me. Perhaps turning to Google' ...

Aligning form fields using CSS and Bootstrap 4

I am struggling to center a form on my page. The labels are centered, but the input with the form-control class is not cooperating. Currently, it appears like this... [EDIT: I have identified that the display: block; within form-control is causing the is ...

HTML code displaying a fixed message at the top of the webpage

I'm working on a web page that has a lot of content. I need to have a message always visible at the bottom of the browser window, even when scrolling. Can anyone help me achieve this using simple CSS, HTML, jQuery, or PHP? Thanks! ...

What specific features does CSS3 offer in terms of background-size properties?

Let's delve into my knowledge: $, like in font-size: 14$; em, as in margin: 2em; What other units are out there? ...

What is the best way to reveal the square's id value upon hovering over it exclusively?

In this assignment, I am refraining from using HTML and focusing on JavaScript to create functionality. Here's my progress so far: document.addEventListener("DOMContentLoaded", function () { let button = document.createElement('button' ...

Top method for retrieving CSS variable in a customized Angular directive

I have a question regarding the process of converting the statement below to Angular's renderer2: this.elementRef.nativeElement.style.setProperty( '--primary-color ' , '#455363' ) The above statement modifies a CSS variable in the ...

Adding a PDF generated from an HTML div to an email using Java

I am looking for a solution to convert the contents of an HTML div tag into a PDF file while preserving its associated CSS. This is essential as I will be using Java on the back-end to send emails, and I need to attach the PDF with the CSS intact when send ...

Adding a custom class to a select2 dropdown: How can it be done?

I have customized select2 using CSS with its general classes and IDs. Currently, I am attempting to customize a specific class that will be assigned to select2 and then applied in the CSS. The problem lies not within the select itself, but within its dro ...

Is it feasible to overlay a PNG image on top of a button while still allowing the button to be clickable?

Can you place an image (.png) on top of a button and still make the button clickable? https://i.sstatic.net/9Z8nH.jpg ...

External CSS file unable to load background image as referenced

I am facing an issue with this code in my external CSS file as it doesn't seem to work at all. Strangely, when I move it internally, everything functions perfectly. Any thoughts on what could be causing this discrepancy? html { background-image:url(i ...

Are there CSS styles that target specific elements?

My goal is to design a unique and custom theme for blender.stackexchange. However, I am facing an issue where the rules I implement only affect certain tags when viewed in FF 29.0.1 Despite all tag elements having the same classes, parent elements, etc., ...

Having trouble getting custom select to work with CSS in Firefox?

I want to customize the button (down arrow) located in the right corner of the select box. The HTML code is as follows: <div class="buscaSelect"> <select name="oper"> <option value="value1">Value 1</option> < ...

How can adjustments be made to the height of elements or nodes within vuetify's v-treeview component?

I recently attempted to implement the following code in a custom CSS file, but unfortunately it did not have any effect: .v-treeview-node__root { max-height: 30px; } Does anyone have any recommendations or alternative suggestions? ...

Initially, the OWL Carousel image is not displaying correctly due to incorrect sizing

I am currently working with OWL Carousel and have implemented a code that displays one image at a time, with the next image sliding in every 15 seconds. The width is set to occupy 100% of the screen and I have configured the JavaScript accordingly so that ...

JavaScript fade effects toggle

Do you have a question? In Vue.js, achieving the fade in / fade out effect can be easily done by specifying it through the component. new Vue({ el: '#demo', data: { show: true } }) .fade-enter-active, .fade-leave-active { ...

Wave Filter in SVG

While attempting to create a fisheye-esque filter in my SVG, I came across this interesting codepen example: http://codepen.io/johanberonius/pen/RopjYW The effect works well, but I would like it to be a bit more pronounced. Unfortunately, I am unable to m ...

Is there a way to modify the text color in HTML and CSS without utilizing the color attribute?

For my website, I chose to use a customizable template for the navigation bar. I am looking to modify the color of the underline of the text without changing the actual text color itself. Since the underlining feature and the text need to be in the same se ...

What sets v-app-bar apart from v-toolbar in Vuetify?

Recently, I delved into the world of vuetify and discovered that all vuetify components are enclosed within <v-app>. In order to create a menu for my website, I came across the <v-app-bar> and <v-toolbar> elements in the documentation. ...

Issues with the functionality of customisable list items in a list

I am attempting to customize the appearance of specific list items within a ul element. One li element should be displayed in red font, while another li element should have a hyperlink styled with a different color and an underline rollover effect. The thi ...

Ways to create a noticeable effect on an image button when hovering without causing a shift in the position

Check out my simple script here: http://jsfiddle.net/PA9Sf/ I am looking to make a specific button stand out when hovered over without affecting the position of other buttons on the page. The current implementation in the provided jsfiddle moves the butto ...