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

    Q-card "on-hover"

    Help
    3
    11
    3580
    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.
    • metalsadman
      metalsadman @mboeni last edited by metalsadman

      @mboeni add a class on your card with :hover selector.

      .my-card:hover
        background-color: yellow
      
      mboeni 2 Replies Last reply Reply Quote 0
      • mboeni
        mboeni @metalsadman last edited by mboeni

        @metalsadman Thanks for the tip.

        I found a way which kinda also works for me:

                    <div v-if="infoBlock.channelUrl !== '' ">
                        <q-card-section class="q-ma-xs infoBlock">
                        <q-img
                          :src='infoBlock.image'
                          basic
                          @click='imgClicked(infoBlock.channelUrl)'
                        >
                        </q-img>
                        </q-card-section>
                      </div>
                      <div v-else>
                        <q-card-section class="q-ma-xs" >
                        <q-img
                          :src='infoBlock.image'
                          basic
                          @click='imgClicked(infoBlock.channelUrl)'
                        >
                        </q-img>
                        </q-card-section>
                      </div>
        

        and this on the scss side:

        .infoBlock {
            background-color:(var(--q-color-primary))
        }
        .infoBlock:hover {
          background-color:(var(--q-color-accent))
        }
        

        Although I don’t like the duplicated code…

        I’ll give @mouseover a shot too.

        Cheers,
        Michael

        PS: This is the result:

        b255356a-e100-48fa-a235-0fe7c8abbb3d-image.png

        1 Reply Last reply Reply Quote 0
        • mboeni
          mboeni @metalsadman last edited by

          @metalsadman yep, that’s what I did…see code below 🙂

          metalsadman 1 Reply Last reply Reply Quote 0
          • metalsadman
            metalsadman @mboeni last edited by metalsadman

            @mboeni you can do it like this

            .infoBlock {
                background-color:(var(--q-color-primary))
                &:hover {
                  background-color:(var(--q-color-accent))
                }
            }
            
            // or with sass
            .infoBlock
              background-color:(var(--q-color-primary))
              &:hover
                background-color:(var(--q-color-accent))
            mboeni 1 Reply Last reply Reply Quote 0
            • mboeni
              mboeni @metalsadman last edited by

              @metalsadman Interesting…although this gives me a different effect:

              b7e80f79-6dd2-4c42-ac9b-88dbe6a25147-image.png

              Now the image is included in the highlighting…:o

              metalsadman 1 Reply Last reply Reply Quote 0
              • metalsadman
                metalsadman @mboeni last edited by

                @mboeni it shouldn’t unless you set the class on your image itself. https://codepen.io/metalsadman/pen/PoPQMWY

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

                  The code still does this:

                               <div v-if="infoBlock.channelUrl !== '' ">
                                  <q-card-section class="q-ma-xs infoBlock">
                                  <q-img
                                    :src='infoBlock.image'
                                    basic
                                    @click='imgClicked(infoBlock.channelUrl)'
                                  >
                                  </q-img>
                                  </q-card-section>
                                </div>
                                <div v-else>
                                  <q-card-section class="q-ma-xs" >
                                  <q-img
                                    :src='infoBlock.image'
                                    basic
                                    @click='imgClicked(infoBlock.channelUrl)'
                                  >
                                  </q-img>
                                  </q-card-section>
                                </div>
                  

                  I’m doing it on the card section that wraps the image…

                  metalsadman 1 Reply Last reply Reply Quote 0
                  • metalsadman
                    metalsadman @mboeni last edited by

                    @mboeni same result see update https://codepen.io/metalsadman/pen/PoPQMWY.

                    1 Reply Last reply Reply Quote 0
                    • R
                      reks last edited by

                      @metalsadman I reviewed your code,
                      instead of changing background color, how to change “image src” on hover

                      metalsadman 1 Reply Last reply Reply Quote 0
                      • metalsadman
                        metalsadman @reks last edited by

                        @reks bind your img src to a data property that you change with on mousehover event handler.

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