What steps should I take to correct the alignment of this grid using CSS?

I'm currently working on creating a grid layout for my website and I've almost achieved the desired result. However, I'm facing an issue with the size of the "Projects" title within the grid. I want it to stand out and be larger compared to the other sections.

Here's what I have so far: https://i.sstatic.net/AfDJh.png

But I aim to create something like this: https://i.sstatic.net/7rSwg.png

HTML:

<div class="project-container">
      <div className="title">
        <h1>PROJECTS</h1>
      </div>
      <div className="project-one item">
        <h2>Face Recognition</h2>
        <button className="button button1">VIEW PROJECT</button>
      </div>
      <div className="project-two item">
        <h2>Face Recognition</h2>
        <button className="button button1">VIEW PROJECT</button>
      </div>
      <div className="project-three item">
        <h2>Face Recognition</h2>
        <button className="button button1">VIEW PROJECT</button>
      </div>
    </div>

CSS:

.project-container {
  width: 80%;
  height: 80vh;
  margin: auto;
  display: grid;
  border: 1px solid pink;
  // grid-gap: 4em;
  grid-template-columns: repeat(3, 1fr);
  grid-template-areas:
    "t t t"
    "p1 p2 p3";
}

.item {
  text-align: center;
  color: white;
  border: 1px solid pink;
}

.title {
  grid-area: t;
  text-align: center;
  border: 1px solid pink;
}

Answer №1

Try utilizing the grid-template-rows property.

.project-container {
  width: 80%;
  height: 80vh;
  margin: auto;
  display: grid;
  border: 1px solid pink;
  // grid-gap: 4em;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 100px auto;
  grid-template-areas:
    "t t t"
    "p1 p2 p3";
}

Answer №2

Hey there, have you considered using css flexbox? I've put together a code snippet that could assist you, and it's completely responsive. For creating a solid masonry layout, css grid is also a good option.

    .project_container {
  padding: 20px;
  margin-bottom: 2em;
  position: relative;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  background-color: #f7f7f7;
  border-radius: 7px;
  box-sizing: border-box;
  font: normal 16px/1.9em sans-serif;
}
.wrap {
  color: #292929;
  font-size: 18px;
  line-height: 1.8em;
  border: 0;
  vertical-align: baseline;
  margin: 0;
  background-color: #f7f7f7;
  border-radius: 3px;
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.title {
  background-color: #a2cbfa;
  border: 1px solid #4390e1;
  text-align: center;
  font-size: 18px;
  color: black;
  -webkit-text-fill-color: #a2cbfa;
  -webkit-text-stroke-width: 1px;
  -webkit-text-stroke-color: black;
  vertical-align: center;
  box-sizing: border-box;
  box-shadow: 0 2px 2px rgba(0, 90, 250, 0.05), 0 4px 4px rgba(0, 90, 250, 0.05),
    0 8px 8px rgba(0, 90, 250, 0.05), 0 16px 16px rgba(0, 90, 250, 0.05);
  height: 100%;
  margin-bottom: 2%;
  width: 100%;
}

.item {
  color: #292929;
  font-size: 18px;
  line-height: 1.8em;
  vertical-align: baseline;
  border-radius: 3px;
  background-color: #a2cbfa;
  -webkit-text-fill-color: #a2cbfa;
  -webkit-text-stroke-width: 1px;
  -webkit-text-stroke-color: black;
  border: 1px solid #4390e1;
  box-sizing: border-box;
  box-shadow: 0 2px 2px rgba(0, 90, 250, 0.05), 0 4px 4px rgba(0, 90, 250, 0.05),
    0 8px 8px rgba(0, 90, 250, 0.05), 0 16px 16px rgba(0, 90, 250, 0.05);
  height: 250px;
  margin-bottom: 2%;
  text-align: center;
  margin-right: 2%;
  flex-grow: 1;
}
.project-three {
  margin-right: 0px;
}
button {
  outline: none;
  border: none;
  border-radius: 3px;
  padding: 5px 10px;
  font-weight: light;
  -webkit-text-fill-color: #292929;
  color: #292929;
  -webkit-text-stroke-width: 0px;
  -webkit-text-stroke-color: none;
  font-size: 12px;
  letter-spacing: 1px;
}
   

 <div class="project_container">
      <div class="wrap">
          <div class="title">
            <h1>PROJECTS</h1>
          </div>
          <div class="project-one item">
            <h2>Face Recog</h2>
            <button class="button button1">VIEW</button>
          </div>
          <div class="project-two item">
            <h2>Face Recog</h2>
            <button class="button button1">VIEW</button>
          </div>
          <div class="project-three item">
            <h2>Face Recog</h2>
            <button class="button button1">VIEW</button>
          </div>
        </div>
        </div>

HAPPY CODING!

Best regards, Sameer

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Centering the Navbar in Bootstrap 3.0

I am currently in the process of migrating my project from Bootstrap 2.3.2 to Bootstrap 3. Unfortunately, I am facing issues with centering the navbar links, something that I was able to do easily before. Previously, I used this method: Center bootstrap&# ...

New programmer seeking to apply a dim effect to the entire photo while also adding a highlight when the image is hovered over

I am looking to add a special effect to my photos where they appear dimmed but highlighted when hovered over. Any guidance on how to achieve this would be greatly appreciated! The image is contained within a flexbox div that also contains a clickable lin ...

Tips for arranging Angular Material cards in columns instead of rows

I am currently developing a web application using Angular, and I've encountered an issue while trying to display cards in a vertical layout rather than horizontally. My goal is to have the cards fill up the first column (5-6 cards) before moving on to ...

The menu field remains open even after clicking on the menu

I have encountered an issue with my code. Here is a DEMO that I created on jsfiddle.net Currently, when you click on the red div, the menu opens. However, if you click on the menu items, the menu area does not close. What do I need to do in order to clo ...

What could be causing the unexpected white gap within my div element even though I've adjusted its dimensions to be minimal?

<div style=" height:0; width: 0 ; border: 1px solid black ; "> This code snippet displays a div element with a specified height, width, and border color. However, there seems to be an issue with the rendering as some st ...

I'm having trouble getting my modal to open, it just displays the information on my page instead

I am encountering some difficulties with my model window. I would like it to open a modal that shows a larger version of the photo and description when the thumbnail is clicked. However, I have not been able to get it to work properly. The only time it pop ...

Easily convert 100% of the height to pixels

Is there a way in HTML to convert a div's height from 100% to pixels without specifying a particular pixel value? ...

The most effective method for positioning a child element to the left and top using Flexbox grid

I am currently working on visualizing queues and processes within a system. Each process is associated with a specific queue from which it retrieves data. I aim to create a layout similar to the following: https://i.stack.imgur.com/BXyts.png However, I a ...

Learn how to manipulate the DOM by dynamically creating elements and aligning them on the same line

Providing some context for my page: The section I have always contains a single input field. Below that, there is an "add" button which generates additional input fields. Since only one field is required on the screen, the following fields come with a "de ...

Trouble with Bootstrap Modal not closing properly in Chrome and Safari

ISSUE: I'm facing a problem where clicking on the X (font awesome icon) doesn't close the modal popup as expected. https://i.sstatic.net/yXnwA.jpg LIMITED FUNCTIONALITY ON CERTAIN BROWSERS: Currently, the X button for closing the modal works o ...

Turn off scrolling for the body content without removing the scrollbar visibility

Whenever I click a thumbnail, a div overlay box appears on top: .view-overlay { display:none; position:fixed; top:0; left:0; right:0; bottom:0; overflow-y:scroll; background-color:rgba(0,0,0,0.7); z-index:999; } Some browsers with non-f ...

Polymer elements fail to adapt to varying screen sizes

I am currently working on creating a responsive website using polymer, but I have encountered an issue where certain elements (such as core-toolbar and paper-fab) are not scaling properly on smaller, denser screens like smartphones. After browsing through ...

Blank space on the lower portion of my website as I attempt to implement a responsive layout

Working on making my webpage responsive for iPad and mobile devices. While adjusting the media query, I noticed a white area at the bottom of the page that seems to be outside the body element. Unsure of where it's coming from. Any help would be great ...

Is feature recognition possible in a jQuery plugin?

Can I integrate a tool similar to Modernizr into my plugin? I want to be able to test for specific CSS3 properties without starting from scratch. ...

The div element is not extending all the way to the left side of the browser window

I'm having trouble positioning a menu at the top of my webpage following a tutorial. The menu icon doesn't seem to reach all the way to the left side of the page. Despite multiple attempts to adjust the margin and padding settings, I can't ...

Automatically close an element when you click on a different element

Hello everyone! I need some help again. I'm working on a script that displays an overlay when a menu item is clicked. Within this menu, there is a modal contact form with a close icon or anchor that should appear when clicked. My goal is to have the o ...

Is there a way to retrieve the immediate children of all elements using CSS selectors in Selenium?

Although I attempted to utilize the ">" syntax, selenium does not seem to accept it. I am aware that Xpath can be used to obtain what I need, however our project exclusively utilizes CSS selectors. My goal is to create a list containing only the immedi ...

CSS - Is there a way to alter the arrangement of DIVs depending on the size of the screen?

My inquiry pertains to a CSS layout. I currently have 3 divs positioned in a horizontal line next to each other, as depicted below... div1 div2 div3 I am aiming for the divs to reorganize themselves as the screen size decreases. In one scenario, they sho ...

5 horizontal navbar with dropdown menu in Bootstrap

I am currently utilizing bootstrap 5. Is it possible to display my navbar menus horizontally like the image provided? show submenus horizontally as shown in this picture I would also like to implement submenu for other submenus up to 4 levels deep. Any ...

trouble concerning the responsiveness of a jQuery popup

Hello, I am trying to create a responsive login popup using jQuery but have been struggling for a week. Below is the code snippet that I have been working on. Any help or guidance would be greatly appreciated. //scriptLogin.js archive $(document).ready ...