Align text in card to the bottom right of the image - vue.js

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.

Related

How stay on the same tab after page refresh with Vuetify Vuejs

I couple tabs on my page and I'm trying to stay on the same tab after refreshing the page but I'm not sure how to approach this. Right now if I'm on TAB-2 and I refresh the page, it will take me back to the first tab.
<v-tabs vertical>
<v-tab>
<v-icon left>mdi-account</v-icon>
TAB-1
</v-tab>
<v-tab>
<v-icon left>mdi-lock</v-icon>
TAB-2
</v-tab>
v-tab-item>
<v-card flat>
<v-card-text>
<p>
TAB-1 Sed aliquam ultrices mauris. Donec posuere vulputate arcu. Morbi ac felis. Etiam feugiat lorem non metus. Sed a libero.
</p>
</v-card-text>
</v-card>
</v-tab-item>
<v-tab-item>
<v-card flat>
<v-card-text>
<p>
TAB -2 Morbi nec metus. Suspendisse faucibus, nunc et pellentesque egestas, lacus ante convallis .
</p>
</v-card-text>
</v-card>
</v-tab-item>
</v-tabs
use sessionStorage to save v-model value of <tabs> temporarily
such as this
created(){
this.model = sessionStorage.getItem('key');
},
methods:{
handleChange(index){
sessionStorage.setItem('key', index);
}
}

Disable scrolling and handle Close method for Sidebar in BootstrapVue

I would like to ask 2 questions about Sidebar in BootstrapVue.
Disable scrolling after opened Sidebar
How to handle closing method when click outside the Sidebar (Backdrop)
I'm using https://bootstrap-vue.org/docs/components/sidebar
<template>
<div>
<b-button v-b-toggle.sidebar-backdrop>Toggle sSidebar</b-button>
<b-sidebar
id="sidebar-backdrop"
title="Sidebar with backdrop"
backdrop
shadow
>
<div class="px-3 py-2">
<p>
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis
in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
</p>
<b-img src="https://picsum.photos/500/500/?image=54" fluid thumbnail></b-img>
</div>
</b-sidebar>
</div>
</template>
Thank you and appreciate.
You can remove the scrollbar by adding the bootstrap class overflow-hidden to your body.
Hook a method up to the #change method on the sidebar, which is fired when the sidebar is shown and hidden.
The sidebar also has a #hidden event, which is fired when the sidebar gets hidden.
new Vue({
el: '#app',
methods: {
toggleBodyScrollbar(visible) {
const body = document.getElementsByTagName('body')[0];
if(visible)
body.classList.add("overflow-hidden");
else
body.classList.remove("overflow-hidden");
}
}
})
<link href="https://unpkg.com/bootstrap#4.4.1/dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://unpkg.com/bootstrap-vue#2.13.0/dist/bootstrap-vue.css" rel="stylesheet" />
<script src="https://unpkg.com/babel-polyfill/dist/polyfill.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.js"></script>
<script src="https://unpkg.com/bootstrap-vue#2.13.0/dist/bootstrap-vue.js"></script>
<div id="app">
<b-sidebar id="sidebar-1" title="Sidebar" shadow backdrop #change="toggleBodyScrollbar">
<div class="px-3 py-2">
<p>
Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis
in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.
</p>
<b-img src="https://picsum.photos/500/500/?image=54" fluid thumbnail></b-img>
</div>
</b-sidebar>
<p v-for="i in 10">Some content</p>
<b-button v-b-toggle.sidebar-1>Toggle Sidebar</b-button>
<p v-for="i in 10">Some content</p>
</div>

vuetify: manually play persistent dialog refuse to close animation

When you click outside a persistent dialog, it will play a animation and dialog will not close, I would like to play this animation when form validation fail and dialog refuse to close
I cannot find any information at vuetify doc, would like to have some pointer to find this out, I am new to java framework and have no idea how I can drag into the source to find out any hint on this.
UPDATED
Dialog has a method called animateClick, you can call the same.
CODEPEN
<div id="app">
<v-app id="inspire">
<v-container fill-height>
<v-row>
<v-col align=center>
<v-btn color="primary" #click="dialog = true">Open</v-btn>
<v-col>
</v-row>
</v-container>
<v-dialog ref="dialog" v-model="dialog" width="400px">
<v-card >
<v-card-title
class="headline grey lighten-2"
primary-title
>
Privacy Policy
</v-card-title>
<v-card-text>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
</v-card-text>
<v-divider></v-divider>
<v-card-action>
<v-btn #click="doAnimation">Animate Me</v-btn>
</v-card-action>
</v-card>
</v-dialog>
</v-app>
</div>
<script>
export default{
...
methods: {
methods:{
doAnimation(){
this.$refs.dialog.animateClick()
}
}
}
}
</script>

How to shift v-flex elements away from one another in Vuetify?

in my vuejs application, I have a file called ProductDetails.vue. For the template, I used Vuetify to create a grid system where the product's image will be at the left, and the product's content to the right. However, I have encountered two problems. Firstly, how do i shift the images and content away from one another so that there is space. Secondly, how to shift the button to the right most of the product's content. Below is my code, a screenshot of my current design and a screenshot of my desired design.
https://codepen.io/Issaki/pen/qwRWgZ
Update #1: I am still trying to solve this issue, is there anyone that can help me?
<template>
<div>
<v-container>
<v-layout row wrap>
<v-flex xs12 sm6 md5 lg5>
<v-img
class="white--text"
height="350px"
src="https://cdn.vuetifyjs.com/images/cards/docks.jpg"
/>
</v-flex>
<v-flex xs12 sm6 md7 lg7>
<p class="subheading font-weight-light grey--text text--darken-1 mb-1">Samsung</p>
<p class="display-1 font-weight-light">OnePlus 3</p>
<p
class="subheading"
>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p class="headline font-weight-medium">$329</p>
<p class="muted">Inclusive of all taxes. Free home delivery.</p>
<v-btn color="yellow">
<v-icon left>shopping_cart</v-icon>Add to Cart
</v-btn>
</v-flex>
</v-layout>
</v-container>
</div>
</template>
You can add space between the two v-flex if you simply add some padding to one of them. So by adding class="pl-3" which translates to padding-left-3 to the second v-flex you can add some space. You can learn more about spacing helpers.
For the button just wrap it in:
<v-layout align-end justify-end>
<v-btn color="yellow" >
<v-icon left>shopping_cart</v-icon>Add to Cart
</v-btn>
</v-layout>
You can learn more about it here.
Update: A better way to add spacing though would be to add grild-list-* to your container. In that case it will add some spacing to all your elements in the container so you dont need the added padding anymore. You can see the updated Codepen below and read more here.
I have forked and edited your Codepen.
Hope it helps :)

Bootstrap Gutters seem not to be working

Am trying Bootstrap 3.
2 columns but they are not between gutters.
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6 box">
<div>
<h3 class="green size-16">Test</h3>
</div><!--first stack-->
<div class="col-md-12">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tellus cursus, porttitor nisi vitae, laoreet metus. Pellentesque felis sapien, ullamcorper vel massa vel, pharetra efficitur diam.
</div><!--second stack-->
</div><!--first box-->
<div class="col-xs-12 col-sm-6 col-md-6 box">
<div>
<h3 class="green size-16">Test</h3>
</div><!--first stack-->
<div class="col-md-12">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras vitae tellus cursus, porttitor nisi vitae, laoreet metus. Pellentesque felis sapien, ullamcorper vel massa vel, pharetra efficitur diam.
</div><!--second stack-->
</div><!--second box-->
</div>
Bootstrap css in head and js at bottom of the body. I do see the padding showing on inspect element, but all boxes are glued to one another so it looks like all in a box.
I might have overlooked smthing, but I tested on jsfiddle and it showed that it worked correctly. It is strange that on html file, it wasnt working as it should.
help appreciated
One more thing
Even with cheating addition to css: margin: 15px, the col-md-4 boxes becomes 2 columns instead of 3 columns. Is it because of the wrapper being in max-width: 1200px?
Actually, this is correct and it's how Bootstrap is designed. The padding affects the content within the grid divs, not the div themselves. I've tweaked your example and made a bootply (my prefered tool - sorry) http://www.bootply.com/8hj7p5Engy.
The content is nicely "guttered" and padded away from neighbor content, but when you add a background or border to the div, then it looks off.
If you're looking for bordered or colored containers around your content, you should probably look at using a Bootstrap .well or .panel