Home > Mobile >  How can I make my image get smaller according to my screen size in mobile version
How can I make my image get smaller according to my screen size in mobile version

Time:10-13

I am a newbie. I want my img to fit and get smaller as I decrease the size of the screen. I tried giving width: 100%; but didn't work. My picture stays still in the screen, doesn't change at all. This is what I want it to be: https://www.freecodecamp.org/news/content/images/2020/09/Animated-GIF-downsized-2-.gif

@import url("https://fonts.googleapis.com/css2?family=Open Sans&family=Poppins:wght@400;600&display=swap");

html,
body {
  width: 100%;
  height: 100%;
  margin: 0px;
  padding: 0px;
  overflow-x: hidden;
  font-family: "Kumbh Sans", sans-serif;
  font-weight: 400;
  background-color: hsl(257, 40%, 49%);
  background-image: url(./images/bg-desktop.svg);
}

.container {
  max-width: 1360px;
  margin: 0 auto;
}

.main {
  display: flex;
}

.logo {
  height: 3rem;
  margin: 40px 5px 60px;
}

.hero-img {
    width: 70%;
  margin-right: 3rem;
}

.hero-text {
  margin-top: 3rem;
  width: 46%;
  color: rgb(211, 211, 211);
  font-size: larger;
}

h1 {
  font-family: "Poppins", sans-serif;
  color: rgb(255, 255, 255);
  margin-bottom: 1rem;
}

p {
  font-size: 1.4rem;
  line-height: 1.3;
}

button {
  color: hsl(257, 40%, 49%);
  padding: 0.8rem 3rem;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  margin-top: 1rem;
  box-shadow: 0px 0.3px 5px black;
}

button:hover {
  background-color: hsl(300, 69%, 71%);
  color: white;
}

.social {
  position: absolute;
  right: 150px;
}

.social a i {
  color: white;
  font-size: 18px;
  position: relative;
}

.social a {
  margin-left: 2rem;
}

.social a:not(:first-child) {
  margin-left: 2rem;
}

.social a i::after {
  content: "";
  position: absolute;
  height: 30px;
  width: 30px;
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  left: -10px;
  bottom: -8px;
  right: 5px;
}

.social a:nth-child(2) {
  margin-left: 2.4rem;
}

.social a:hover i {
  color: hsl(300, 69%, 71%);
}

.social a i:hover::after {
  border-color: hsl(300, 69%, 71%);
}

@media only screen and (max-width: 1200px) {
  /* .container {
        display: flex;
        flex-direction: column;
    } */

  .hero-img {
  
  }

  .social {
  }
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <!-- displays site properly based on user's device -->

    <link
      rel="icon"
      type="image/png"
      sizes="32x32"
      href="./images/favicon-32x32.png"
    />

    <title>
      Frontend Mentor | Huddle landing page with single introductory section
    </title>

    <!-- Feel free to remove these styles or customise in your own stylesheet            
  • Related