Tryingprogrammer
Tryingprogrammer

Reputation: 61

grid image is not going into place

I am trying to get the image on section-1 to go to the right side, however it is not working. I have tried using flex-box but I want the picture to be stay on the right side of the screen and not move. I have also tried using floats, but that disrupts the whole section beneath it, so I decided to use grid. I have set it to display grid and set the columns but it is still not working.

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  width: 100%;
  height: 50px;
  background-color: white;
  display: flex;
  line-height: 50px;
}

.navbar .container {
  align-items: center;
  display: flex;
}

.navbar-list {
  display: flex;
  margin: auto;
}

.navbar-list ul li {
  align-items: center;
  margin-left: 20px;
}

.navbar-list li a {
  margin-left: 20px;
  color: var(--pureblack);
}


/*section 1*/

.section-1 {
  display: grid;
  grid-template-columns: auto 400px;
}

.mockups {
  height: 400px;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  overflow-x: hidden;
}

body {
  font-family: "Source Sans Pro", sans-serif;
  font-weight: 400;
  font-size: 0.875rem;
  line-height: 1.6;
  letter-spacing: 0;
  color: var(--font-color-base);
  margin: 0;
  padding: 0;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
<nav id="topNav" class="navbar nav">
  <div class="container flex">
    <img src="/easybank-landing-page-master/images/logo.svg" alt="company logo" />
    <ul class="navbar-list">
      <li>
        <a href="">Home</a>
      </li>
      <li>
        <a href="">About</a>
      </li>
      <li>
        <a href="">Contact</a>
      </li>
      <li>
        <a href="">Blog</a>
      </li>
      <li>
        <a href="">Careers</a>
      </li>
    </ul>
    <button class="btn btn-green">Request invite</button>
  </div>
</nav>
<section class="section-1 container">
  <div class="container">
    <div class="left">
      <h3>Next generation digital banking</h3>
      <p>
        Take your financial life online. Your Easybank account will be a one-stop-shop for spending, saving, budgeting, investing, and much more.
      </p>
      <button class="btn btn-green">Request Invite</button>
    </div>
    <div class="right">
      <img src="/easybank-landing-page-master/images/image-mockups.png" alt="mockups" class="mockups" />
    </div>
  </div>
</section>

Upvotes: 0

Views: 381

Answers (2)

Mohamed Zahour
Mohamed Zahour

Reputation: 338

The grid doesnt work with position. You should remove position in class navbar.

Upvotes: 1

RatajS
RatajS

Reputation: 1429

Set the parent of .left and .right as the grid container, like this:

.section-1 .container {
  display: grid;
  grid-template-columns: auto 400px;
}

It works for me this way.

Your code placed the whole .container div into the left column.

Upvotes: 0

Related Questions