'Vue div display grid remove extra space between rows
I am new to Vue and for this project, I was trying to display 2 players in each row for a div. I solved that using display: grid; CSS as on playerDiv id. The issue is I am having right now is it creates a huge gap in between the first, second, and third rows. Is there a way to remove that gap between each rows?
I am using height as 440px for playerDiv and 30px for eachPlayerDiv. I cannot change that as sometimes the database value on todos can be just 2 players or 12 players. Is there a way to solve that gap issue without changing height as I have defined?
Currently it displays as
Player 1 Player 2
Player 3 Player 4
Player 5 Player 6
Is there a way to display players as
Player 1 Player 2
Player 3 Player 4
Player 5 Player 6
JsFiddle Link = https://jsfiddle.net/ujjumaki/f0js3pLa/25/
View
<div id="app">
<div id="playerDiv">
<div v-for="element in todos" class="eachPlayerDiv">
{{element.text}}
</div>
</div>
</div>
<style>
#playerDiv{
height:440px;
background-color: white;
display: grid;
grid-template-columns: 1fr 1fr;
background-color:red;
}
.eachPlayerDiv{
border-style:solid;
background-color:yellow;
height: 30px;
}
</style>
Methods
new Vue({
el: "#app",
data: {
todos: [
{ text: "David", id: 1 },
{ text: "John", id: 2 },
{ text: "Alek", id: 3 },
{ text: "Joshua", id: 4},
{ text: "Jonny", id: 5},
{ text :"Sam", id:6}
]
},
methods: {
toggle: function(todo){
todo.done = !todo.done
}
}
})
Solution 1:[1]
Wrap the grid within a container that is defined as flexbox. Remove the 440px height from the grid-container and apply it to the flexbox container. That you can use the vertical-align (align-item) to center the grid without gap between the rows.
//for demonstration purpose only
document.querySelector('#playerDiv').innerHTML = '<div class="eachPlayerDiv">Box 1</div><div class="eachPlayerDiv">Box 2</div><div class="eachPlayerDiv">Box 3</div><div class="eachPlayerDiv">Box 4</div><div class="eachPlayerDiv">Box 5</div><div class="eachPlayerDiv">Box 6</div>';
.wrapper {
height: 440px;
display: flex;
align-items: center; /* vertical center */
border: 1px solid red; /* for demo purpose only */
}
#playerDiv {
flex-grow: 1; /* let the grid consume the entire width */
background-color: white;
display: grid;
grid-template-columns: 1fr 1fr;
background-color: red;
}
.eachPlayerDiv {
border-style: solid;
background-color: yellow;
height: 30px;
}
<div id="app">
<div class="wrapper">
<div id="playerDiv">
<div v-for="element in todos" class="eachPlayerDiv">
{{element.text}}
</div>
</div>
</div>
</div>
Solution 2:[2]
then I realized there is a hidden .git folder which size is 80Gb
If your .git folder is that big and that you are doing Unity development, I really hope that you are using git-lfs.
Otherwise you did a big mistake and you will have to fix that (and it's much more complicated if you don't have free space anymore so I won't answer here)
If you are using git-lfs, you can cleanup objects not used anymore with the command: git lfs prune
Only after that and if it made some free spaces, then you could do a git gc
So I went to Git GUI and pressed on compressed and it consumed all of my free space in my disk, the command didn't even finished.
If it behave like that and failed to compress the git object, that probably means that you didn't enabled git-lfs and so git has difficulties to compress your big binaries assets so you will have to enable it and convert your whole git history to use it. But before ensure that the git hosting you are using is supporting it...
For your migration, things like that could help:
- https://docs.gitlab.com/ee/topics/git/lfs/migrate_to_git_lfs.html
- https://notiz.dev/blog/migrate-git-repo-to-git-lfs
And I'm not sure it could be done when your disk is full. So maybe you will have to make free space or copy your repository elsewhere and do the work from there (it still a good idea to do a copy as a backup before starting to do these things).
Buy an external hard drive if needed...
Unity with Git: https://thoughtbot.com/blog/how-to-git-with-unity
Solution 3:[3]
Git history can take up a lot of space, even if big files aren't on the latest branch.
You can remove all Git history for the repo and have the current state become the initial state:
As seen from: https://stackoverflow.com/a/26000395
- Checkout
git checkout --orphan latest_branch
- Add all the files
git add -A
- Commit the changes
git commit -am "commit message"
- Delete the branch
git branch -D main
- Rename the current branch to main
git branch -m main
- Finally, force update your repository
git push -f origin main
That will free up a lot of space in your .git folder.
Also see: Make the current commit the only (initial) commit in a Git repository?
(This is essentially the same solution I posted in https://stackoverflow.com/a/70742570/7058266)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | tacoshy |
| Solution 2 | |
| Solution 3 | Michael Mintz |
