Image gallery is what we often see on sites, and I personally like the masonry image gallery. I thought to create it and when I saw the demo I didn't get the idea at first. How could I create this div position randomly, as fitting with each other seems to be impossible without CSS or jQuery. I thought I would have to use a jQuery plugin for this, then an idea came in my mind: Why div?
We just need the output, so why shouldn't I do this with a table? We can do this in div also but I am not too good in CSS, so I preferred a table.
Here's the image and code of the aspx page,
Image Aspx Page


Aspx code
I shared the .aspx page code above, we created six classes with different heights and background colors. I took a div, gave an id and made it runnable at the server side by giving runat="server", so that we can access this at code behind.
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- <style>
- .inner-tr td {
- vertical-align: top;
- }
- .one-tiles {
- height: 170px !important;
- background-color: #d77575;
- }
- .two-tiles {
- height: 130px !important;
- background-color: #dcbc4c;
- }
- .three-tiles {
- background-color: #a3ca3b;
- height: 300px !important;
- }
- .four-tiles {
- background-color: #3daee3;
- height: 150px !important;
- }
- .five-tiles {
- background-color: #bb8ed8;
- height: 270px !important;
- }
- .six-tiles {
- background-color: #baafb1;
- height: 230px !important;
- }
- </style>
- </head>
- <body>
- <form id="form1" runat="server">
- <div id="divmain" runat="server" class="box">
- </div>
- </form>
- </body>
- </html>


kalu singh raoPosted Jul 1, 2016, 3:01 PM
Nice...
Harinder KumarPosted Jul 1, 2016, 2:34 PM
Amazing sir m sure that must be a very helpful article for both freshers and experienced !!