I want to change background color when change screen size at Bootstrap 3

喜夏-厌秋 提交于 2019-12-14 03:07:06

问题


I'm using bootstrap 3. I have a header with transparent red background, but I want to change it according to screen size changes.

For example:

  • At lg size, background-color will be red
  • At sm size, background-color will be pink

回答1:


You can just use Media Queries

/* Large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    h1 {
        background: rgba(255, 0, 0, 0.5);     /* transparent red */
    }
}

/* Anything Smaller than Large  */
@media (max-width: 1199px) {
    h1 {
        background: rgba(255, 192, 203, 0.5); /* transparent pink */
    }
}

jsFiddle



来源:https://stackoverflow.com/questions/19438584/i-want-to-change-background-color-when-change-screen-size-at-bootstrap-3

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