最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Material UI breakpoints to set orientation: portrait and landscape view - Stack Overflow

programmeradmin0浏览0评论

Would like to be able to set portrait and landscape views on the styles object for tablets in Material UI

const styles = theme => ({
  root: {
    padding: theme.spacing.unit,
    [theme.breakpoints.up('md')]: {
      backgroundColor: theme.palette.secondary.main
    }
  }
}

how can i add breakpoints for portrait view and landscape view similar to the traditional media query:

@media screen and (orientation: landscape) {
  body {
    flex-direction: row;
  }
}

@media screen and (orientation: portrait) {
  body {
    flex-direction: column;
  }
}

Would like to be able to set portrait and landscape views on the styles object for tablets in Material UI

const styles = theme => ({
  root: {
    padding: theme.spacing.unit,
    [theme.breakpoints.up('md')]: {
      backgroundColor: theme.palette.secondary.main
    }
  }
}

how can i add breakpoints for portrait view and landscape view similar to the traditional media query:

@media screen and (orientation: landscape) {
  body {
    flex-direction: row;
  }
}

@media screen and (orientation: portrait) {
  body {
    flex-direction: column;
  }
}
Share Improve this question edited Sep 6, 2018 at 17:54 Julio Cornelio asked Sep 3, 2018 at 13:08 Julio CornelioJulio Cornelio 1711 gold badge2 silver badges6 bronze badges 1
  • 1 what issue you're facing ? – Sakhi Mansoor Commented Sep 3, 2018 at 13:09
Add a comment  | 

3 Answers 3

Reset to default 10

Just set something like that:

const styles = theme => ({
  root: {
    padding: theme.spacing.unit,
    [`${theme.breakpoints.up('md')} and (orientation: portrait)`]: {
      flexDirection: 'column'
    }
  }
}

You're able to use something like this:

'@media (orientation: landscape)': {
  flexDirection: `orientation`,
},

for the component media query will be attached.

Used this in version 4.11.1

const useStyles = makeStyle((theme) =>({
    container:{
        border:"1px dashed red",
        [theme.breakpoints.down("md")]{
           border: "1px solid blue",
           '@media (orientation: landscape)': {
              border: "1px solid green",,
            },
        },
    },
}));
发布评论

评论列表(0)

  1. 暂无评论