I am a student and working on a school project. I'm working on a responsive grid with 3 columns whenever u resize the widow the image should stay at 100% and only be visible once.
I came into an error with it, when full screen it takes up the full width but when i resize the widow the section overlay each other and only come back to full width (like they are supposed to be at phone size, mediaquery)
code snippet:
.container {
width:100%;
height:700px;
}
.columns {
float:left;
width:33.33%;
height:100vh;
}
.blue {
background-color: #92d2fc;
background-image: url(https://placeholdit.imgix.net/~text?txtsize=33&txt=460%C3%97800&w=460&h=800);
}
.yellow {
background-color: #fad74e;
background-image: url(https://placeholdit.imgix.net/~text?txtsize=33&txt=460%C3%97800&w=460&h=800);
}
.red {
background-color: #f88888;
background-image: url(https://placeholdit.imgix.net/~text?txtsize=33&txt=460%C3%97800&w=460&h=800);
}
.blue img, .red img, .yellow img {
width:100%;
}
@media screen and (max-width: 700px){
.columns {
width:100%;
}
}
<div class="container">
<section class="columns blue">
<h3>About us</h3>
<p class="margin-top">How the gym became a reality</p>
</section>
<section class="columns yellow">
<h3>Manifesto</h3>
<p class="margin-top">Respect the rules</p>
</section>
<section class="columns red">
<h3>Contact us</h3>
<p class="margin-top">Have a chat with us</p>
</section>
</div>
Thanks in advance! Distortion
I'm not sure I 100% understand your question, but it sounds like your problem is the fixed-width of the background image? Try something like
background-size: contain;
in your.columns
class, or giving the background-size some percentage values.