How can I make my Vuetify layout use all the available vertical space? - layout

I inherited a project where I need the layout to use as much viewport space as possible both horizontally and vertically, and resize nicely too.
My layout is pretty simple, with 2 main rows split in two columns. I need to make it so the two main "cells" (marked "Main 1" and "Main 2" in the code below) expand vertically to use as much vertical space as possible.
My understanding is this can be achieved using a <v-container fluid fill-height>. But while the horizontal part works perfectly well, I can't get this layout to expand vertically.
Here is my App.vue file (simplified for the purpose of this post):
<template>
<v-app>
<v-main>
<v-container fluid fill-height>
<v-row>
<v-col cols="6" class="yellow">Header 1</v-col>
<v-col cols="6" class="yellow">Header 2</v-col>
</v-row>
<v-row>
<v-col cols="8" class="pink">
<v-row>
<v-col cols="5" class="red">Main 1</v-col>
<v-col cols="7" class="red">Main 2</v-col>
</v-row>
<v-row>
<v-col cols="12" class="red">Bottom</v-col>
</v-row>
</v-col>
<v-col cols="4" class="pink">Right</v-col>
</v-row>
</v-container>
</v-main>
</v-app>
</template>
<style scoped>
.yellow { border: 1px dotted yellow }
.red { border: 1px dotted red }
.pink { border: 1px dotted pink }
</style>
<script setup>
</script>
I also did set up a Vuetify playground for live testing.

OK, I hope this is what you were looking for. Notice how I made use of Vuetify's flex utility classes on the container and some of the rows. These classes are there to help you layout your page with flexbox. You can read more about it here.
<template>
<v-app>
<v-main class='d-flex'>
<v-container fluid fill-height class='d-flex flex-column'>
<v-row class='flex-grow-0'>
<v-col cols="6" class="yellow">Header 1</v-col>
<v-col cols="6" class="yellow">Header 2</v-col>
</v-row>
<v-row>
<v-col cols="8" class="pink d-flex flex-column">
<v-row>
<v-col cols="5" class="red">Main 1</v-col>
<v-col cols="7" class="red">Main 2</v-col>
</v-row>
<v-row class='flex-grow-0'>
<v-col cols="12" class="red">Bottom</v-col>
</v-row>
</v-col>
<v-col cols="4" class="pink">Right</v-col>
</v-row>
</v-container>
</v-main>
</v-app>
</template>

Related

Vuetify Grid system adding a horizontal scroll bar in my dialog

Good day. I have the following dialog that whenever i add anything inside it's component an horizontal scrollbar shows up and the right of my dialog suddenly has a space on it's right side. like in reference pic
This right here all the code i have:
My view:
<template>
<v-main>
<v-dialog
v-model="dialog"
>
<v-card background-color="white">
<div>
<myComponent/>
</div>
</v-card>
</v-dialog>
<v-container>
// rest of my code
</v-container>
</main>
</template>
My Component:
<template>
<v-main>
<v-row align='center' justify="center">
<v-col class="d-flex justify-center" cols="5">
hello
</v-col>
</v-row>
</v-main>
</template>
Why does this happen exactly. Every page i has scooped styles and most of them don't even have any css applied to it. When i remove the "hello" together with the v-col tags the dialog goes back to normal like so:
Add style="overflow-x: hidden;" to your div that is wrapped around <myComponent/>

Color change causes icon to not show on svg version of font-awesome 5

I'm using the latest version of font-awesome svg+js. I can only change the color of the icons with inline style.
Whenever I add a class, the icon stops showing and it becomes a flashing exclamation point.
This is a small fiddle showing the problem https://jsfiddle.net/CaioSantAnna/Lb5dpo7v/7/
<script defer src="https://use.fontawesome.com/releases/v5.8.2/js/all.js"></script>
<span class="fa-4x" style="background: #4CAF50">
<i class="far fa-circle" style="color:white"></i>
<i class="far fa-circle fa-white"></i>
</span>
<style type="text/css">
.fa-white{
fill:#ffffff;
color: #ffffff;
}
</style>
Is it possible to achieve the inline result with a common css class ?
Thanks.
Apparently the prefix fa-for an additional class will cause an error. The solution would be using an extra class without the prefix: for example white instead of fa-white
.white{
fill:#ffffff;
color: #ffffff;
}
<script defer src="https://use.fontawesome.com/releases/v5.8.2/js/all.js"></script>
<span class="fa-4x" style="background: #4CAF50">
<i class="far fa-circle"></i>
<i class="far fa-circle white"></i>
</span>
An alternative solution would be using the prefixed class on the wrapping span:
.fa-white{
fill:#ffffff;
color: #ffffff;
}
<script defer src="https://use.fontawesome.com/releases/v5.8.2/js/all.js"></script>
<span class="fa-4x fa-white" style="background: #4CAF50">
<i class="far fa-circle"></i>
<i class="far fa-circle"></i>
</span>

vuetify center items into v-flex

I'm trying to center a <v-btn> into a <v-flex>. Since <v-flex> is a flexbox div, I use justify-center that is transformed into
justify-content: center
Since my direction is horizontal, my button should be center aligned but it's not. Here is the codepen that reproduce my problem.
https://codepen.io/anon/pen/ZXLzex
I want to signup the button to be centered inside the div (v-flex).
Here is the full code:
<v-card>
<v-card-text >
<v-text-field label="Email"></v-text-field>
<v-text-field label="Password"></v-text-field>
</v-card-text>
<v-card-actions>
<v-layout row>
<v-flex justify-center>
<v-btn primary>
Signup
</v-btn>
</v-flex>
</v-layout>
</v-card-actions>
</v-card>
wrap button inside <div class="text-xs-center">
<div class="text-xs-center">
<v-btn primary>
Signup
</v-btn>
</div>
Dev uses it in his examples.
For centering buttons in v-card-actions we can add class="justify-center" (note in v2 class is text-center (so without xs):
<v-card-actions class="justify-center">
<v-btn>
Signup
</v-btn>
</v-card-actions>
Codepen
For more examples with regards to centering see here
<v-layout justify-center>
<v-card-actions>
<v-btn primary>
<span>SignUp</span>
</v-btn>
</v-card-actions>
</v-layout>
It works for me using the v-layout in the following way:
<v-layout justify-center>
<div class="text-center ma-5">
<v-card-actions>
<v-btn primary>
<span>LogIn</span>
</v-btn>
</v-card-actions>
</div>
</v-layout>
vuetify's v-layout allows you to modify all the elements inside the layout.
v-flex does not have a display flex!
Inspect v-flex in your browser and you will find out it is just a simple block div.
So, you should override it with display: flex in your HTML or CSS to make it work with justify-content.

Align photos and captions in a grid

I'm trying to align four pictures with their captions in a square grid.
I'm using the following HTML code:
<div class="grid">
<div class="post-block">
<img src="img1.jpg" />
<div class="caption">caption1</div>
</div>
<div class="post-block">
<img src="img2.jpg" />
<div class="caption">caption2</div>
</div>
<div class="post-block">
<img src="img3.jpg" />
<div class="caption">caption3</div>
</div>
<div class="post-block">
<img src="img4.jpg" />
<div class="caption">caption4</div>
</div>
</div>
and the following CSS code:
.post-block {
display: inline-block;
position: relative;
text-align: center;
}
If images and captions are the same size everything is ok, but when they are different I get this (an example):
I've tried to align images and captions of different sizes using CSS with no success. I need something like this:
Any help would be appreciated.
Thanks in advance
You'll need to use separate block elements at the same DOM level for the image and the caption to achieve what you've shown in the "RIGHT" image. Right now your caption DIV is nested inside the image DIV, and that's gonna do what you've shown. The caption DIV needs to be outside the image DIV.
You will probably want two separate div wrappers around each 2 photos..
Then align images vertically to bottom.
Vertical align images to bottom
<div class="myWrapClass">
<img src="my image">
<img src="my image">
</div>
<div class="myWrapClass">
<img src="my image">
<img src="my image">
</div>
then set the styling via inline or your css file
<div style="vertical-align:bottom;">
or
.myWrapClass{
vertical-align:bottom;
}
check out this site... Use the css properties there to keep it responsive
Example

Bootstrap: fluid layout with no external margin

if i have:
<div class="container-fluid">
<div class="row-fluid">
<div class="span8">
Some Element....
</div>
<div class="span4">
Other Element
</div>
</div>
</div>
With this code i have some margin from left and right window borders. How can eliminate these margins?
Thanks for your support
If i understand your question correctly, I believe you want this:
.container-fluid {
padding: 0px;
}
Also if you are using responsive bootstrap you will also want this:
#media (max-width: 797px) {
body {
padding-left: 0px;
padding-right: 0px;
}
}
Edit: here is a js fiddle.
The effect you are seeing is because of the container’s padding.
You can change the container’s default padding with the built-in Bootstrap 4 spacing utility classes.
To remove the padding, add p-0 to the container:
<div class="container-fluid p-0">
<div class="row">
<div class="col-8">
Some Element....
</div>
<div class="col-4">
Other Element
</div>
</div>
</div>
Using the built-in utility classes has the benefit of keeping your CSS lean and it also does not modify the default container-fluid class definition.

Resources