So I have a background-image behind various texts. In CSS it's set to background-size: 1000px;
I'd like it to resize(enlarge) when I widen the viewport window to @media only screen /* Tablet */ and (min-width: 768px) whilst still remaining within the confines of its container (keeping the height and crop is important. I just want to grow the picture to fill the left and right dead space.) I've tried the obvious background-size: 2000px; however, the background-image is sticking to its original 1000px and I don't know why.
.container {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 50px 340px 1fr 50px;
grid-template-areas:
"header"
"advert"
"main"
"footer";
text-align: center;
}
advert {
grid-area: advert;
background: url(./mi-vr-5.jpg);
background-position-x: 50%;
background-position-y: 75%;
background-size: 1000px;
}
@keyframes bg-righttoleft {
0% {
background-position: 20% 75%;
opacity: 0;
}
100% {
background-position: 50% 75%;
}
}
@media only screen /* Tablet */
and (min-width: 768px) {
.container {
grid-template-columns: 1fr;
grid-template-rows: 50px 340px 1fr 50px;
grid-template-areas:
"header"
"advert"
"main"
"footer";
}
advert {
background-repeat: no-repeat;
font-size: 0.7em;
background-size: 2000px;
}
}
@keyframes bg-righttoleft {
0% {
background-position: 200% 75%;
opacity: 0;
}
100% {
background-position: 50% 75%;
}
}
<advert class="bg-righttoleft">
<div class="title-shift">
<h1 class="title text-style">How to VR</h1>
<h3 class="title-shift-h3 text-style">Guiding you to the world of VR</h3>
<p class="title-shift-p">Whether you're purchasing your first VR headset or simply interested we're here to answer all of your questions.</p>
</div>
<div class="channel">
<h3 class="chan-text">Review of the week</h3>
<a href="https://www.youtube.com/channel/UC-6OW5aJYBFM33zXQlBKPNA">
<img class="chan-img" src="./engadget.jpg" alt="Engadget logo"></a>
</div>
</advert>