Quiero hacer un carrusel que ocupe todo el ancho y alto de una ventana gráfica. Estoy usando Vuetify en un proyecto vue.js 2. Aquí está mi código:
<head> <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.x/css/materialdesignicons.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"> </head> <body> <div id="app"> <v-app> <v-main> <v-container fill-height> <v-carousel cycle hide-delimiters style="height: 100%;"> <v-carousel-item> <v-sheet color="red lighten-1" fill-height style="height: 100%"> <v-row class="fill-height" align="center" justify="center" > <div class="text-h2"> Slide One </div> </v-row> </v-sheet> </v-carousel-item> <v-carousel-item> <v-sheet color="warning" style="height: 100%"> <v-row class="fill-height" align="center" justify="center" > <div class="text-h2"> Slide Two </div> </v-row> </v-sheet> </v-carousel-item> </v-carousel> </v-container> </v-main> </v-app> </div> <script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script> <script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script> <script> new Vue({ el: '#app', vuetify: new Vuetify(), }) </script> </body>
Estoy usando la última versión de Opera GX para renderizarlo y estoy usando vue serve para servirlo.
Retire el relleno del v-container aplicando una class de pa-0 (establece p agregando en todos los lados a 0 ).
Elimine el margen y el ancho máximo de v-container configurando su propiedad fluid en true (agregar el atributo es suficiente para configurarlo en true ).
En v-carousel , elimine el enlace de style , ya que está anulado por su accesorio de height . En su lugar, establezca la height de v-carousel en 100% .
<v-container class="pa-0" 1️⃣ fluid 2️⃣ fill-height> <v-carousel height="100%" 3️⃣ ⋯> <head> <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.x/css/materialdesignicons.min.css" rel="stylesheet"> <link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"> </head> <body> <div id="app"> <v-app> <v-main> <v-container class="pa-0" fluid fill-height> <v-carousel height="100%" cycle hide-delimiters> <v-carousel-item> <v-sheet color="red lighten-1" fill-height style="height: 100%"> <v-row class="fill-height" align="center" justify="center"> <div class="text-h2"> Slide One </div> </v-row> </v-sheet> </v-carousel-item> <v-carousel-item> <v-sheet color="warning" style="height: 100%"> <v-row class="fill-height" align="center" justify="center"> <div class="text-h2"> Slide Two </div> </v-row> </v-sheet> </v-carousel-item> </v-carousel> </v-container> </v-main> </v-app> </div> <script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script> <script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script> <script> new Vue({ el: '#app', vuetify: new Vuetify(), }) </script> </body>