Struggling to organize elements in a grid layout using CSS from my database. Despite all efforts, the items keep aligning to the left instead of forming a proper grid https://i.sstatic.net/5SfJZ.jpg
I've attempted various methods to grid the items, but nothing seems to work.
Here is the JavaScript code I'm using:
var html = "";
html += "<center>";
html += "<div id='post'><div id='post-head'>";
html += snap.val().title;
html += "</div> <div id='post-id'> <p>";
html += snap.val().post;
html += "</p></div>";
var pic = snap.val().image;
if (pic != "empty") {
html += "<div id='post-img'>";
html += "<img src='"+pic+"' id='post-pic'>";
html += "</div>";
html += "<p align='right' id='snal'> By : Havoshing Admin</p>";
html += "<br><small id='gray'>";
html += snap.val().time1;
html += "</small>";
} else {
html += "<br><small id='gray'>";
html += snap.val().time1;
html += "</small>";
}
html += "</div>";
html += "</center><br><br><br>";
document.getElementById("content").innerHTML += html;
Below is my attempt at styling it with CSS:
#content {
display: grid;
grid-template-columns: 50% 50%;
padding: 10px;
}
Please assist me in identifying where I may be going wrong. Your help is much appreciated!