Stacking V-Card children overlaps and misaligns - vue.js

I'm trying to stack a v-card-title on top of a v-card-subtitle and then v-card-text and the text is overlapping. Don't these elements vertically stack by default?:
<v-main>
<v-container fluid style="padding:0px">
<v-row no-gutters>
<v-col :cols="12" :md="6">
<v-card
height='100%'
style="position: relative"
elevation="0">
<v-card-title
class="header">
lorem ipsum dolor
</v-card-title>
<v-card-subtitle class="subHeader">
lorem ipsum dolorlorem ipsum dolorlorem ipsum dolorlorem ipsum dolor
</v-card-subtitle>
<v-card-text class="subText">
lorem ipsum dolorlorem ipsum dolorlorem ipsum dolorlorem ipsum
dolor lorem ipsum dolor dolor lorem ipsum dolor dolor lorem ipsum
dolor
</v-card-text>
</v-card>
</v-col>
<v-col :cols="12" :md="6">
<v-img :src="{myImage}"></v-img>
</v-col>
</v-row>
{...about 4 more rows identical to above...}
</v-container>
</v-main>
and here are my styles:
.header{
font-family: 'Cormorant Garamond', serif;
font-size: 85px;
}
.subHeader{
font-family: 'Montserrat', sans-serif;
font-size: 28px;
}
.subText{
font-family: 'Montserrat', sans-serif;
font-size: 15px;
letter-spacing: 1.5px;
color:#333;
}
and then if I try to vertically + horizontally center everything using this on the v-card, everything then lines up horizontally:
class="d-flex align-center justify-center"
What am I just not getting here?

Using d-flex turns your card into a flexbox container transforming direct children elements. What you're seeing is the default behavior of flex children. They display in a row because by default the flex-direction property is set to row. Read more at MDN Web Docs.
Anyway, you don't need to use d-flex in this case. Vuetify provides a helper class fill-height that will center the contents of the v-container. From the docs:
fill-height applies height: 100% to an element. When applied to v-container it will also align-items: center.
For example:
new Vue({
el: '#app',
vuetify: new Vuetify(),
})
<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">
<div id="app">
<v-app>
<v-main>
<v-container fluid fill-height style="padding:0px">
<v-row no-gutters justify=center>
<v-col cols="6">
<v-card class="" elevation="2" >
<v-card-title class="header">
lorem ipsum dolor
</v-card-title>
<v-card-subtitle class="subHeader">
lorem ipsum dolorlorem ipsum dolorlorem ipsum dolorlorem ipsum dolor
</v-card-subtitle>
<v-card-text class="subText">
lorem ipsum dolorlorem ipsum dolorlorem ipsum dolorlorem ipsum dolor lorem ipsum dolor dolor lorem ipsum dolor dolor lorem ipsum dolor
</v-card-text>
</v-card>
</v-col>
</v-row>
</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>

Related

Veutify v-card doesn't align properly when controlling it's width within a timeline component

Using an example from their official website, I'm attempting to control the width of a v-card that is being used within a timeline component. When I added max-width="400px" to the the v-card component the timeline items that render on the left side no longer align within the center as such.
<div id="app">
<v-app id="inspire">
<v-timeline
align-top
:dense="$vuetify.breakpoint.smAndDown"
>
<v-timeline-item
v-for="(item, i) in items"
:key="i"
:color="item.color"
:icon="item.icon"
fill-dot
>
<v-card
:color="item.color"
dark
max-width="400px"
>
<v-card-title class="text-h6">
Lorem Ipsum Dolor
</v-card-title>
<v-card-text class="white text--primary">
<p>Lorem ipsum dolor sit amet, no nam oblique veritus. Commune scaevola imperdiet nec ut, sed euismod convenire principes at. Est et nobis iisque percipit, an vim zril disputando voluptatibus, vix an salutandi sententiae.</p>
<v-btn
:color="item.color"
class="mx-0"
outlined
>
Button
</v-btn>
</v-card-text>
</v-card>
</v-timeline-item>
</v-timeline>
</v-app>
</div>

Align text to different directions in a Vuetify slider

I have the following slider
Vue.config.productionTip = false;
Vue.config.devtools = false;
new Vue({
el: '#app',
vuetify: new Vuetify(),
})
<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#4.x/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify#2.x/dist/vuetify.min.css" rel="stylesheet">
<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>
<div id="app">
<v-app>
<v-carousel
cycle
height="600"
hide-delimiter-background
show-arrows
next-icon
prev-icon
>
<v-carousel-item
:src=`https://picsum.photos/seed/picsum/536/354`
>
<v-row align-end>
<h1 class="white-text">Lorem, ipsum dolor.</h1>
<p class="white-text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Modi quo iusto velit autem, pariatur impedit neque, sed a, rem architecto aut aliquid aspernatur magni quibusdam natus ducimus fugiat. Et, veniam.</p>
<v-btn color="yellow black-text">Hi</v-btn>
</v-row>
</v-carousel-item>
</v-carousel>
</v-app>
</div>
I want for example align the text of the first slide at the bottom-center of the image, I've heard that Vuetify uses flexbox but I'm not sure how it works and I don't even understand the examples from the documentation, so I would like some help. What I want to know the most is where to place the align or justify, I really don't get it.
Try to add the following classes d-flex flex-column justify-end align-center fill-height to the v-row component :
Vue.config.productionTip = false;
Vue.config.devtools = false;
new Vue({
el: '#app',
vuetify: new Vuetify(),
})
<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#4.x/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify#2.x/dist/vuetify.min.css" rel="stylesheet">
<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>
<div id="app">
<v-app>
<v-carousel cycle height="600" hide-delimiter-background show-arrows next-icon prev-icon>
<v-carousel-item :src=`https://picsum.photos/seed/picsum/536/354`>
<v-row class="d-flex flex-column justify-end align-center fill-height">
<h1 class="white-text">Lorem, ipsum dolor.</h1>
<p class="white-text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Modi quo iusto velit autem, pariatur impedit neque, sed a, rem architecto aut aliquid aspernatur magni quibusdam natus ducimus fugiat. Et, veniam.</p>
<v-btn color="yellow black-text">Hi</v-btn>
</v-row>
</v-carousel-item>
</v-carousel>
</v-app>
</div>

Align text in card to the bottom right of the image

I'm trying to use the flex properties in the Vuetify's grid system to align the text to the bottom right of the image but only the justify is working for me, align is doing nothing for me, I tried to use align-end in the v-flex and in the v-layout but neither is working. On top of that, if I add a v-flex the justify that used to work for the v-layout stops working. It's the first day I use Vuetify so I'm a bit lost and overwhelmed with the large number of properties and components it has so I would like some help here:
<v-card>
<v-img src="https://images.pexels.com/photos/3992952/pexels-photo-3992952.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940">
<v-container>
<v-layout justify-end>
<span class="headline white--text">Lorem, ipsum dolor.</span>
</v-layout>
</v-container>
</v-img>
<v-card-title>
<h2>Lorem, ipsum dolor.</h2>
</v-card-title>
<v-card-text>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Optio doloribus tempore distinctio dolorem blanditiis iusto cupiditate accusantium provident consectetur quisquam repellat quo aliquam quia placeat incidunt natus eveniet ipsa ipsum aut, animi suscipit alias sequi. Sapiente totam omnis molestiae adipisci.
</v-card-text>
<v-card-actions>
<v-btn color="info" text>Action</v-btn>
</v-card-actions>
</v-card>
a) flexbox only works on a parent-child basis. You have a few properties aimed at the flex container (the parent) and a few usable on the flex items (the children). Obviously, any flex item can also be a flex container for its own children. For a more in-depth coverage of how flexbox works I recommend this read.
b) whenever something doesn't seem to work right, regardless of the UI framework/library you use, have a look at their examples. Find one that's close to what you're after and simply copy-paste the markup and then start playing.
In your case, you don't need <v-container>, <v-layout> or any of those complications inside <v-img>.
It's way simpler:
<v-card>
<v-img>
<v-card-title />
</v-img>
<v-card-text />
<v-card-actions />
</v-card>
Here's a working example:
Vue.config.productionTip = false;
Vue.config.devtools = false;
new Vue({
el: '#app',
vuetify: new Vuetify(),
})
#app {
margin: 20px 0;
}
<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#4.x/css/materialdesignicons.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/vuetify#2.x/dist/vuetify.min.css" rel="stylesheet">
<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>
<div id="app">
<v-app>
<v-card class="mx-auto" max-width="400">
<v-img class="white--text align-end"
src="https://images.pexels.com/photos/3992952/pexels-photo-3992952.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940">
<v-card-title class="justify-end">Lorem, ipsum dolor.</v-card-title>
</v-img>
<v-card-text>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Optio doloribus tempore distinctio dolorem blanditiis iusto cupiditate accusantium provident consectetur quisquam repellat quo aliquam quia placeat incidunt natus eveniet ipsa ipsum aut, animi suscipit
alias sequi. Sapiente totam omnis molestiae adipisci.
</v-card-text>
<v-card-actions>
<v-btn large color="primary">Action</v-btn>
</v-card-actions>
</v-card>
</v-app>
</div>
In order to make the title bottom right aligned I used:
.align-end on <v-img> // bottom align
.justify-end on <v-card-title> // align right
Note: justify-end class aligns element contents to the right with two conditions: the item has to be a flex container (a.k.a: have display: flex
- true in the case of <v-card-title>s) and has to have flex-direction: row (which is the implicit/default value).
If it's not a flex container, you have to use text-right class (or, in plain CSS: text-align: right).
Based on flex-direction value (row|row-reverse|column|column-reverse) any of the following would align to the right, accordingly: justify-end|justify-start|align-end|align-start.
So, rather than trying to remember: "justify-end aligns to the right" (which is only true in 1 out of 4 possible cases), visualize flexbox as having a direction. What's left/right of that direction is controlled by align-*. What's front/back on that direction is controlled by justify-*.
You dont need to use v-container or v-layout in this case, just need to add align-end class on your v-img and justify-end class on the image title.
<!-- your sample code -->
<v-card>
<v-img class="align-end" src="https://images.pexels.com/photos/3992952/pexels-photo-3992952.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940">
<v-card-title class="justify-end">Lorem, ipsum dolor.</v-card-title>
</v-img>
<v-card-title>
<h2>Lorem, ipsum dolor.</h2>
</v-card-title>
<v-card-text>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Optio doloribus tempore distinctio dolorem blanditiis iusto cupiditate accusantium provident consectetur quisquam repellat quo aliquam quia placeat incidunt natus eveniet ipsa ipsum aut, animi suscipit alias sequi. Sapiente totam omnis molestiae adipisci.
</v-card-text>
<v-card-actions>
<v-btn color="info" text>Action</v-btn>
</v-card-actions>
</v-card>
You can always get example from Vuetify official documentation.

Vuetify Fullscreen property not creating an element with height:100%

I am still very new to the Vue.js and Vuetify frameworks. I am currently trying to create a front page element with a css property of height:100% in Vuetify, but for some reason I am unable to fill the page with the first row element.
As seen below, I am using the "fullscreen" Vuetify property in the v-row element.
Thanks!
<template>
<div class="home">
<v-row class="grey fullscreen" align="center" justify="space-around">
<v-col xs=12 md=5>
<h1 class="main-title">Clever and<br> Practical Designs<span class="redDot">.</span></h1>
<h3 class="sub-title">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Quo exercitationem repellat, officia consequuntur obcaecati voluptate cum voluptas placeat dolores temporibus vel ex saepe reprehenderit porro asperiores cumque distinctio accusantium optio.</h3>
<v-row>
<v-btn href="" class="button white--text pa-4">
View our Products
</v-btn>
</v-row>
</v-col>
<v-col xs=12 md=5>
<v-img contain class="homeimg" max-width="500px" src="../assets/Large_product.png"></v-img>
</v-col>
</v-row>
</div>
</template>
I found a solution:
Adding a style element in the App.vue file to get the fullscreen class to function properly :
<template>
<v-app>
<Navbar />
<v-content>
<router-view></router-view>
</v-content>
</v-app>
</template>
<script>
import Navbar from '#/components/Navbar'
export default {
name: 'App',
components: { Navbar },
data: () => ({
//
}),
};
</script>
<style lang="scss">
.fullscreen {
width: 100%;
height: 100vh;
}
</style>

Vuetify v-card overflows on IE11

I am trying to use a v-card with vuetify 2.x. The card overflows on IE11 even though its max-width is set to 90%.
I imported the following in main.js for browser compatibility.
import Es6Promise from 'es6-promise';
import 'babel-polyfill';
Es6Promise.polyfill();
My card is defined in the template as follows:
<template>
<v-layout column>
<v-card class="mx-auto pa-4" max-width="90%">
<v-card-title>Test</v-card-title>
<v-card-text class="text-justify">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent
</v-card-text>
</v-card>
</v-layout>
</template>
Try to add div tag in the v-card content, then you could add <br> tag to add new line, or add CSS style (such as the word-wrap: break-word property) on the div tag to prevent content overflow.
sample code like this:
<div id="app">
<v-app id="inspire">
<v-card class="mx-auto" max-width="344" >
<v-card-text>
<div>Word of the Day</div>
<p class="display-1 text--primary">
be•nev•o•lent
</p>
<p>adjective</p>
<div class="text--primary">
well meaning and kindly.<br>
"a benevolent smile"
</div>
</v-card-text>
<v-card-actions>
<v-btn text color="deep-purple accent-4" > Learn More </v-btn>
</v-card-actions>
</v-card>
</v-app>
</div>