No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Best way to accomplish masonry layout of divs (v1.0 beta 8)?

    Framework
    3
    5
    905
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ssuess
      ssuess last edited by

      Hi, I have a number of divs of varying heights (but identical widths) in a prefs page I am building, and I would like to have the layout be a masonry type so that I am not leaving blank space. Is there anything within Quasar that would help with this, or do I need to build the layout with css and js on my own? Thanks!

      1 Reply Last reply Reply Quote 0
      • ssuess
        ssuess last edited by

        For now I found a lightweight, easy to use component to accomplish this: vue-masonry-css (https://paulcollett.github.io/vue-masonry-css/demo/).

        1 Reply Last reply Reply Quote 1
        • G
          gkentsidis last edited by

          Hi, I have the same issue. Can you please tell how did you implemented that component and used it? I followed the instructions provided with no success.

          gvorster 1 Reply Last reply Reply Quote 0
          • ssuess
            ssuess last edited by

            I actually ended up going with packery instead, it was more adapted to my needs. I used this component: https://github.com/t-k-f/vue-packery-plugin

            1 Reply Last reply Reply Quote 0
            • gvorster
              gvorster @gkentsidis last edited by gvorster

              @gkentsidis said in Best way to accomplish masonry layout of divs (v1.0 beta 8)?:

              Hi, I have the same issue. Can you please tell how did you implemented that component and used it? I followed the instructions provided with no success.

              I tried this and it looks nice.
              Small example using Quasar 1.14 and Vue composition api.

              yarn add vue-masonry-css
              quasar new b vue-masonry
              

              Add vue-masonry boot file to quasar.conf.js

              import Vue from 'vue'
              import VueMasonry from 'vue-masonry-css'
              
              Vue.use(VueMasonry);
              

              Small test page wirth random length text:

              <template>
                <q-page padding>
                  <masonry :cols="3" :gutter="10">
                    <div v-for="(item, index) in items" :key="index" class='card q-ma-md'>
                      <span>{{item}}</span>
                    </div>
                  </masonry>
                </q-page>
              </template>
              
              <script>
              import { ref } from "@vue/composition-api";
              
              export default {
                // name: 'PageName',
              
                setup() {
                  let items = ref([])
              
                  for (let i=0; i<=25; i++) {
                    let s = ""
              
                    for (let n=1; n <= Math.floor(Math.random() * 15); n++) {
                      s += "xxxxxx xxxxxx xxxxxxxxxxxxx xxxxxxxx "
                    }
              
                    items.value.push(s)
                  }
              
                  return { items }
                }
              };
              </script>
              
              <style lang='stylus'>
              .card
                border: 1px solid black;
              
              
              </style>
              
              

              Output
              Selection_010.png

              Using it in my little private code snippet library.
              Selection_011.png

              1 Reply Last reply Reply Quote 1
              • First post
                Last post