The layout of my CSS grid item is slightly off, but the overall result is nearly accurate

Exploring the realms of CSS grid on my website has led me to create an intriguing "add friend" menu design. The layout I am aiming for is depicted in this visual representation:

https://i.sstatic.net/vg2T8.png

Here is a snippet of the HTML and SCSS code being used:

.container {
    height: 100%;
    display: grid;
    align-items: center;
    grid-template-columns: 70% 30%;
    grid-template-rows: 20% 60% 20%;
    gap: 10px;

    .grid-item {
        height: 100%;
        padding: 20px;

        .grid-item-input {
            grid-column: 1 / 2;
        }

        .grid-item-button {
            grid-column: 2 / 3;
        }

        .grid-item-content {
            grid-column: 1 / 3;
        }

        .grid-item-exitbutton {
            grid-column: 1 / 3;
        }
    }
}
<div class="container">
  <div class="grid-item grid-item-input">
    <ion-item>
      <ion-label position="fixed">Username</ion-label>
      <ion-input></ion-input>
    </ion-item>
  </div>

  <div class="grid-item grid-item-button">
    <ion-button color="primary">Add Friend</ion-button>
  </div>

  <div class="grid-item grid-item-content">
    <ion-text>Friend</ion-text>
    <ion-text color="tertiary">
      Lorem ipsum dolor sit, amet consectetur adipisicing elit. Aperiam maxime vel temporibus quidem repellendus. Dolore sed, ipsa esse harum excepturi quae assumenda recusandae repellendus! Error sunt et labore, architecto magni quaerat sit molestiae eligendi est itaque, corrupti optio ratione enim aliquam perspiciatis ab, dolor maxime sint rem eveniet maiores quidem.
    </ion-text>
  </div>

  <div class="grid-item grid-item-exitbutton ion-text-center">
    <ion-button color="danger">
      <ion-icon name="close-outline"></ion-icon>
    </ion-button>
  </div>
</div>

The current outcome almost matches the intended design, but there seems to be an issue with the placement of the "exit" button.

https://i.sstatic.net/nettC.png

I have highlighted the spot where the button should be located using a green marker. You can refer back to the above layout to confirm this discrepancy.

My main inquiry is:

In the SCSS file, I have explicitly specified that the grid-item-exitbutton should span from the first column to the second column using "grid-column: 1 / 3". However, it ends up in the second row instead of spanning as expected.

What could be causing this unexpected behavior?

Answer №1

.wrapper {
    height: 100%;
    display: grid; 
    grid-template-columns: 7fr 3fr;
    grid-template-rows: 1fr 3fr 1fr;
    gap: 10px;    
}

.item-content, .item-closebutton {
  grid-column: 1 / -1;  
}

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

Learn how to display HTML content in trNgGrid using the $sce.trustAsHtml method

I am currently working with a table that has search options implemented using trNgGrid.js. The data for this table comes from a Sharepoint list where one of the columns contains HTML content that I need to display. To achieve this, I attempted using $sce. ...

The coloring of my div elements is not displaying as intended

After reviewing the provided html and css, I am puzzled as to why the parent container is being colored green while the child items remain uncolored. It seems like all div elements are being affected by the green color. What I actually want is for the pa ...

Creating a personalized scroll bar for an Angular Material Table while retaining the original table styles

Is there a way to maintain the table style of an Angular Material table while using a custom scrollbar with a transparent background? Currently, the issue arises when the scrollbar has an extended width, causing the table style to disappear. https://i.ss ...

Show an image when hovering over a dot using CSS - without hovering directly on the image

I'm currently working on a merchandising page that involves photoshopping several products onto a background image. I want customers to be able to hover over a dot positioned on each product to reveal its information and provide a link similar to . Ho ...

Having trouble setting the background of a div in CSS

How can I apply the background-color: #f8f8f8 class to the step class without interfering with the display of the horizontal lines after 1, 2? What could be causing this issue? .main-progress { text-align: center; position: relative; margin- ...

Tips on getting rid of the excess margin added by Android WebView printing

We have been attempting to print content from a webview via Google Cloud Print, but no matter what steps we take, the resulting printout always includes an unwanted margin. Is there a solution to eliminate this margin? We have tried: <body style="marg ...

Is there a way to modify the style value within AngularJS?

<div class="meter"> <span style="width: 13%"></span> </div> I have the following HTML code snippet. I am looking to update the width value using AngularJS. Does anyone have a solution for this issue? ...

unable to choose an option if more than one radio button is being used

I am having trouble with two radio buttons that are supposed to select the gender of an applicant and the gender of the applicant's child. Both buttons are not functioning properly. Can someone assist me with this issue? Here is the code I am using: ...

In Angular/Typescript, dynamically add a class to a `td` element when it is clicked. Toggle the class on and off

My problem arises when trying to individually control the arrow icons for each column in my COVID-19 data table. By using Angular methods, I aim to show ascending and descending arrows upon sorting but run into the challenge of changing arrows across all c ...

DomSanitizer in Angular is not able to bind to an Angular component

Trying to dynamically insert HTML content into a DIV has been successful when done statically. The following code is functioning properly: <popover-content #pop1 title="Cool Popover" placement="right" ...

Can someone help me troubleshoot this issue with my code so that my website can open in a blank page using about:blank?

I'm currently facing an issue while trying to make one of the pages on my website open with an about:blank URL upon loading. Despite embedding the code in my index.html file, it doesn't seem to be functioning properly. Here's the code I&apos ...

Button for Selecting Colors

I love the color picker button on Google Keep, where a variety of colors pop up for selection. I'd like to add something similar to my website. What steps should I take to implement this feature? ...

The background appears only in the upper portion of the screen upon refreshing the table

Whenever the user clicks on the edit button or when the page is initially loading, a backdrop appears and disappears once the modal is displayed. The backdrop effectively highlights the entire page. However, after updating my table with data via Ajax witho ...

Issue encountered with sortable table in list.js

Encountering a puzzling error while implementing list.js and tabletop for a sortable table sourced from a Google Doc. The error message reads: "Uncaught TypeError: Cannot read property 'childNodes' of undefined," pinpointing the first line in lis ...

JavaScript can be used to create dynamic frames within a

Can anyone help identify the issue in my code? frame 1 <script type="text/javascript"> var Clicks = 0 ; function AddClick(){ Clicks = Clicks + 1; document.getElementById('CountedClicks').innerHTML = Clicks ; } localStorage.setItem(' ...

Tips for preventing <v-layouts> from impacting one another

I'm currently working on a dynamic link box for a homepage website, which can be viewed at . Inside this link box, I have included a button that allows the creation of buttons that function as links. Interestingly, the layouts of both the options but ...

Problem with the purity of :global() CSS-module selectors in NextJS

Currently in the process of migrating an app from CRA to NextJS, I've encountered an issue with the .module.scss files of certain components and pages: Syntax error: Selector ":global(.label-primary)" is not pure (pure selectors must contain ...

Guide to creating adaptive content using React and Material UI

For my current project, I am working on designing a product detail page using React and Material UI. The challenge I am facing is ensuring that the page remains responsive across different screen sizes. Specifically, I am struggling with the description se ...

prevent parent jQuery functions from interfering with child function execution

I am facing an issue with conflicting jQuery functions between parent and child elements. The child function is a bootstrap function, while the parent is a custom function. The main objective is to limit the height of the parent div (refer to the code belo ...

Changing the Style of a CSS Module Using JavaScript

Embarking on a journey into Javascript and React, I am currently working on my first React app. My aim is to adjust the number of "gridTemplateRows" displayed on the screen using a variable that will be updated based on data. Right now, it's hardcode ...