How to do breakpoints in scss file with vuetify?

青春壹個敷衍的年華 提交于 2021-02-07 12:52:33

问题


How to use media query breakpoints in my vuetify application but in scss file?

For example bootstrap enable me to do that in scss file:

@include media-breakpoint-up(sm) {
  .custom-class {
    display: block;
  }
}

what is the equivalent in vuetify? I can't find any documention in vuetify website


回答1:


You can do it in scss:

@import '~vuetify/src/styles/settings/_variables';

@media #{map-get($display-breakpoints, 'sm-and-down')} {
    .custom-class {
        display: block;
    }
}

... and you're right there is very little docs regarding breakpoints within vuetify




回答2:


I achieved this by attaching a class name corresponding to the breakpoint, which is available in the $vuetify.breakpoint object. Not a perfect solution, but I only needed to do it for once element in my app. Hope it helps!

Example:

<item :class="($vuetify.breakpoint.smAndDown) ? 'sm' : ''"></item>
...
<style scoped lang="scss">
#item{
    right: 130px;
    &.sm{
        right: 35px;
    }
}
</style>


来源:https://stackoverflow.com/questions/55963401/how-to-do-breakpoints-in-scss-file-with-vuetify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!