lundi 21 juin 2021

Responsive Issue - Image Width | HTML,CSS

I have the following code:

@import url('https://fonts.googleapis.com/css?family=Merriweather|Open+Sans');

.blogmaster {
  display: flex;
  margin-top: 0;
  margin-bottom: 0;
}

.container1 {
 display: flex;
  flex-wrap: wrap;
 padding: 20px;
  justify-content: center;
    overflow: hidden;
}

.square {
  margin: 70px;
  position: relative;
  margin-top: 0;
  margin-bottom: 0;
  width: 100%;
  max-width: 460px;
  height: 100% !important;
  background: white;
  border-radius: 4px;
  box-shadow: 0px 5px 20px #D9DBDF;
  -webkit-transition: all 0.3s ease;
  -o-transition: all 0.3s ease;
  transition: all 0.3s ease;
}

.square:hover {
  -webkit-transform: translate(20px, -10px);
  -ms-transform: translate(10px, -10px);
  transform: translate(10px, -10px);
  -webkit-box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
}

.square .square-image img{
 width: 100%;
  height: 250px;
  object-fit: cover;
  border-top-left-radius: 4px;
 border-top-right-radius: 4px;
}
.square .square-details{
  padding: 20px 30px 30px;
}

.h11 {
  margin: auto;
  text-align: left;
  font-family: 'Merriweather', serif;
  font-size: 24px;
}

p0 {
  text-align: justify;
  font-family: 'Open Sans', sans-serif;
  font-size: 12px;
  color: #C8C8C8;
  line-height: 18px;
  margin-top: 10px;
  display: block;
}

.button56 {
  background-color: #3EDD84;
  color: white;
  width: 100px;
  padding: 10px 18px;
  border-radius: 3px;
  text-align: center;
  text-decoration: none;
  display: block;
  font-size: 12px;
  cursor: pointer;
  font-family: 'merriweather';
}

.parent-div {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
}

@media screen and (max-width: 480px) {
  .parent-div {
    flex-direction: column;
  }
}
@media screen and (max-width: 480px) {
.square{
margin: 40px;
margin-bottom: 0;
  ]
}
@media screen and (max-width: 480px) {
.square .square-image img{
width: 100%;
  height: 250px;
  object-fit: cover;
}
}
<section>
  <div class="section-title">
    <h2>Featured Blogs Of The Day</h2>
  </div>

  <div class="row1">
            <div class="container1">
              <div class="square">
                <div class="square-image">
                                  <img src="https://images.unsplash.com/photo-1504610926078-a1611febcad3?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=e1c8fe0c9197d66232511525bfd1cc82&auto=format&fit=crop&w=1100&q=80">
                </div>

                <div class="square-details">
                  <h3 class="h11">“Chances Of My Uni/College Admission?”</h3>
                <p0>It is that time of the year again (yay!🙂) where we — high school students — are supposed to fill out the applications and land in our dream Universities/Colleges!</p0>
                  <div><a href="https://m-hussainomer03.medium.com/chances-of-my-uni-college-admission-20bc0efec0af" target="_" class="button56">Read More</a></div>
                </div>
               
              </div>
              <div class="square">
                <div class="square-image">
                                  <img src="https://www.isfasports.gr/image/cache/data/products/pr_3-1100x1100.jpg">
                </div>

                <div class="square-details">
                  <h3 class="h11">My Career Advice To You: Take These Steps...</h3>
                <p0>Humans tend to make mistakes — and its completely normal as it results in the growth and development of an individual — either psychologically or physically.</p0>
                  <div><a href="https://m-hussainomer03.medium.com/my-career-advice-to-you-take-these-steps-to-ultimate-prosperity-6c0687ce9c9f" target="_" class="button56">Read More</a></div>
                </div>
               
              </div>
            </div>
          </div>


</section>
<!-- End blogs Section -->

Over here, when you run the above code, open it in new page, inspect it to view it on a smaller device, then it works perfectly fine. The image fits the card and that is what I want.

However, I have the above code embedded in a website and so when I view my website on a smaller screen, I am getting this output:

enter image description here

For some reason, the image is centered and does not fit the card.

Expected Output

I am just looking for the image to fit the card. When you run the above code, open it on the new page, inspect it to view on a smaller device, then that is the output I would like. On my end, I am getting that output as shown in the picture above. Any suggestions?




Aucun commentaire:

Enregistrer un commentaire