html - Background image doesn't show on small devices CSS -
background image doesn't show on small devices css. have background image gets zoomed in via css when screen made smaller background image disappears , white. trying make app needs work on devices , sizes. work fine when doesn't zoom in. have pasted code below. thanks
* {-webkit-tap-highlight-color: rgba(0, 0, 0, 0):} body { -webkit-touch-callout: none; /* prevent callout copy image, etc when tap hold */ -webkit-text-size-adjust: none; /* prevent webkit resizing text fit */ -webkit-user-select: none; /* prevent copy paste, allow, change 'none' 'text' */ background-color: #e4e4e4; ); background-attachment: fixed; } /* portrait layout (default) */ .app { position: absolute; /* position in center of screen */ background-position: center; position: relative; bottom: -300px; font-family: 'roboto', sans-serif; } /* landscape layout (with min-width) */ @media screen , (min-aspect-ratio: 1/1) , (min-width:400px) { h1 { font-size: 90px; font-weight: normal; margin: 0px; overflow: visible; padding: 0px; text-align: center; color: white; font-family: 'roboto', sans-serif; } p { color: blue; font-family: 'roboto', sans-serif; font-size: 15px; text-align: center; color: white; } .event { border-radius: 4px; -webkit-border-radius: 4px; color: #ffffff; font-size: 12px; margin: 0px 30px; padding: 2px 0px; } .createanaccount { padding-bottom: 10px; padding-top: 10px; font-size: 15px; } .logintable { text-align: center; } .login { padding-bottom: 10px; padding-top: 10px; font-size: 15px; } .event.listening { background-color: #333333; display: block; } .event.received { background-color: #4b946a; display: none; } @keyframes fade { { opacity: 1.0; } 50% { opacity: 0.4; } { opacity: 1.0; } } @-webkit-keyframes fade { { opacity: 1.0; } 50% { opacity: 0.4; } { opacity: 1.0; } } .blink { animation: fade 3000ms infinite; -webkit-animation: fade 3000ms infinite; } .bg { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: -999; } .background { background: #22313f; background-image: url(https://i.ytimg.com/vi/b7wd- spnx_i/maxresdefault.jpg); background-size: cover; width: 100%; height: 100%; animation: zoom 12s forwards ease-out; html code below
<body> <div class="bg"> <div class="background"></div> </div> <body>
your @media query has minimun pixel limit. if delete this, work. change line
@media screen , (min-aspect-ratio: 1/1) , (min-width:400px) into this
@media screen , (min-aspect-ratio: 1/1) by setting min-width apply background changes if viewport 400 pixels wide or wider.
Comments
Post a Comment