What causes the malfunction of CSS grid?

I have a unique HTML structure that looks like this:

<div>
    <div class="my-grid-container" ng-repeat="cardData in summaryCardsCtrl.summaryDetails">
         <div class="myClass">
             My customized div
         </div>
    </div>
</div>

My goal is to make the first div span across two rows, similar to this example:

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

To achieve this, I am utilizing CSS3 GridBox in the following manner:

.my-grid-container {
  display: grid;
  grid-template-columns: auto auto auto;
  grid-gap: 10px;
  padding: 10px;
}

.my-grid-container > div {
  text-align: center;
  padding: 20px 0;
  font-size: 30px;
  max-height: 70px;
}

.my-grid-container > .myClass:first-child {
    grid-row: 1 / 3;
}

However, my current implementation is not producing the desired result. I want the first div to span two rows and evenly distribute the remaining divs.

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

Can anyone identify what I may be doing wrong? Any assistance would be much appreciated.

UPDATE

Please refer to the provided codepen for further examination: https://codepen.io/chiranjib/pen/vjpOKE

Or, explore the codebase below

var myApp = angular.module('myApp', []);

myApp.controller('CardController', ['$scope', function($scope) {
  $scope.cardData = [
    {'name': 'My Div1', 'quantity': 3, 'price': 1.10},
    {'name': 'My Div2', 'quantity': 2, 'price': 1.99},
    {'name': 'My Div3', 'quantity': 1, 'price': 3.22},
    {'name': 'My Div4', 'quantity': 1, 'price': 3.74}
  ];
}]);
.my-grid-container {
  display: grid;
  grid-template-columns: auto auto auto;
  grid-gap: 10px;
  padding: 10px;
}

.my-grid-container > div {
  /*background-color: rgba(255, 255, 255, 0.8);*/
  background-color: aqua;
  text-align: center;
  padding: 20px 0;
  font-size: 30px;
  height: auto;
}

.my-grid-container > .myClass:first-child {
    grid-row: 1 / 3;
}
<html ng-app="myApp">
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.9/angular.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
  </head>
  <body ng-controller="CardController">
            <div class="my-grid-container" ng-repeat="cardData in cardData">
               <div class="myClass">
                Modified Divs
             </div>
        </div> 
  </body>
</html>

Answer №1

This worked flawlessly. You were mistakenly creating the my-grid-container class in every iteration, which was incorrect.

<div>
    <div class="my-grid-container" >
         <div class="myClass" ng-repeat="cardData in summaryCardsCtrl.summaryDetails">
             My custom div
         </div>
    </div>
</div>

I made changes to the HTML code and added an object to $scope.cardData

var myApp = angular.module('myApp', []);

myApp.controller('CardController', ['$scope', function($scope) {
  $scope.cardData = [
    {'name': 'My Div1', 'quantity': 3, 'price': 1.10},
    {'name': 'My Div2', 'quantity': 2, 'price': 1.99},
    {'name': 'My Div3', 'quantity': 1, 'price': 3.22},
    {'name': 'My Div4', 'quantity': 1, 'price': 3.74},
    {'name': 'My Div5', 'quantity': 1, 'price': 3.74}
  ];
}]);
.my-grid-container {
  display: grid;
  grid-template-columns: auto auto auto;
  grid-gap: 10px;
  padding: 10px;
}

.my-grid-container > div {
  /*background-color: rgba(255, 255, 255, 0.8);*/
  background-color: aqua;
  text-align: center;
  padding: 20px 0;
  font-size: 30px;
  height: auto;
}

.my-grid-container > .myClass:first-child {
    grid-row: 1 / 3;
}
<html ng-app="myApp">
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.9/angular.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
  </head>
  <body ng-controller="CardController">
            <div  class="my-grid-container" >
               <div class="myClass"  ng-repeat="cardData in cardData">
                Modified Divs
             </div>
        </div> 
  </body>
</html>

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

What is the process for disabling the CSS module feature in Next.js?

In Next.js, Global CSS can only be imported in _App.js. However, importing global CSS in every component is not allowed, so we have to use CSS modules to comply with this restriction imposed by Next.js. Currently, I am in the process of migrating a large ...

What is the best way to eliminate the selected text while moving/grabbing an element?

I'm facing an issue with removing the background text image when dragging elements. I have tried troubleshooting but haven't found a solution yet. For reference, I looked at this link: HTML5 Drag and Drop anywhere on the screen function drag_sta ...

Footer stays put as you scroll, peeking out from behind the main content

I'm trying to replicate the sticky-footer effect that can be seen on the website From what I understand, the footer needs to be fixed in place. The content should have a higher z-index. It seems like the body may need a margin-bottom equal to the ...

CSS failed to load on HTML page

Having trouble loading a CSS file. I've attempted: <link href="./css/style.css" rel="stylesheet" type="text/css"> And: <link href="css/style.css" rel="stylesheet" type="text/css"> And even tried without the "css" directory in the name ...

Deleting an element from an array renders the iterator invalid

Looking for a solution in AngularJS to eliminate all categories with a count of 0 from the categories array. // removing categories with zero count i = 0; angular.forEach( $scope.categories, function( category ) { if( category.count == 0) ...

Blending AngularJs Widget with Adobe Captivate for Enhanced Interactivity

I've encountered an issue with integrating AngularJs into Adobe Captivate 8, and I'm starting to question the compatibility between AngularJs and Captivate. Despite having correct design setups in Captivate, I'm uncertain whether the error l ...

Is there a way to showcase whitespacing in HTML?

I have a database full of content that includes whitespace formatting for display on a webpage. However, when viewed on Stackoverflow using the code tag, the formatting changes. The second way shows how it is stored in the database and how I want it to app ...

How can I center an image within another image in a two-column layout?

Hey there, I'm working on a 2-column layout where I need to position an image in the center of another one in the second column. However, my attempts at styling seem to be failing as the image keeps showing up in the top left corner of my page... Her ...

AngularJS closes when clicking anywhere except for the element itself

It's a common occurrence, for example, when you click on the inbox here on stackoverflow. I refer to the dialog or popup that appears as a thing. There are two methods I am aware of to handle this: Creating an invisible overlay where the opened ele ...

Finding the nearest span value upon clicking through a specific class

Whenever a user clicks on a hyperlink, my goal is to locate the nearest span element with a specific class and retrieve the text within that class. As of now, it is only returning blank text: Here is the provided HTML code snippet: <div class="plan re ...

Ensure that the image within the child div occupies the entire height of the parent div

I'm having a bit of trouble figuring this out and could use some input: There's a parent div with an unspecified height, determined by its content. Inside this parent div are two 'child' elements; however, I want only one to dictate t ...

angular pagination directive malfunctioning

I have developed a custom directive for pagination that is compatible with grids throughout my website. On this particular page, there is a search feature that retrieves new data, and I am looking to update the pagination within my directive with this new ...

Is there a way to direct to a specific URL upon clicking a button using PHP?

In my PHP code called registerprocess.php, it executes after clicking a submit button on another page named userregistration.php. If a user tries to register with an email that already exists in the database, I want registerprocess.php to redirect back to ...

creating a text box that matches the dimensions of the one before

I am working on my form and trying to adjust the width of the Address1 text box to match the Last Name text box. The goal is to have the Address1 text box end where the Last Name text box ends. Below is the relevant code snippet: <div class="row"> ...

Achieving Full Screen Height in Angular Component

Trying to nest an angular component within another one that occupies the entire screen using height:100%; in the component's css file. I want to stack them and ensure each component takes up the full screen height, but setting height:100% doesn't ...

Bootstrap Framework 3 causing horizontal scroll due to header styling

Here is the link you requested: This is the HTML Code: <header id="header-10"> </div><!-- /.header-10-top --> <!-- MAIN NAVIGATION --> <div class="header-10-main"> <div class="container"> ...

The application appears differently on a phone compared to how it looks on the ripple platform

Recently started experimenting with Apache Cordova, attempting to create a basic application. Here is how it looks in Google Chrome using Ripple for PhoneGap/Cordova emulation: https://i.sstatic.net/2MSwl.png When I click on the button, this is the resul ...

The Sublime/TAG feature "Eliminate Selected Attributes from Tags" does not support the removal of "data-reactid" attributes

I am attempting to utilize TAG in Sublime Text 3 -- https://github.com/titoBouzout/Tag When I apply the "Remove Picked Attributes From Tags (in Document)" feature with class it successfully eliminates all class attributes. However, when I use it with ...

How can I create a custom message in HTML using Angular directives within a marker popup using the angular-leaflet-directive?

I'm looking to add my own custom HTML markup with $scope event handlers to the message property of a Leaflet marker. Here's an example: App.controller('testController', ['$scope', "leafletEvents", '$compile', ' ...

Seeking assistance with HTML parsing: Struggling to access and parse the complete source code of webhallen.com

When attempting to access and analyze the complete HTML content of this link, I encountered difficulties. Even after clicking "view page source" in my browser, the full HTML code remained inaccessible. ...