Here’s the CSS I used:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*----------Custom Divi Gallery----------*/
.et_overlay {
    display: none;
}
.mfp-title {
    display: none;
}
.et_pb_gallery_grid .et_pb_gallery_item img {
    transform: scale(1.03);
    transition: transform 0.5s, opacity 0.5s;
}
.et_pb_gallery_grid .et_pb_gallery_item img:hover {
    transform: scale(1.15);
    opacity: 1;
}
.et_pb_gallery_grid .et_pb_gallery_item {
    padding: 2px;
    width: 20%!important;
    clear: right!important;
}
@media only screen and (max-width: 479px) {
    
.et_pb_column .et_pb_grid_item:nth-child(n) {
    width: 33%!important;
}
}

For 2 Columns:

1
2
3
4
.et_pb_gallery_grid .et_pb_gallery_item {
    width: 50%!important;
    clear: right!important;
}

For 3 Columns:

1
2
3
4
.et_pb_gallery_grid .et_pb_gallery_item {
    width: 33.33%!important;
    clear: right!important;
}

For 5 Columns:

1
2
3
4
.et_pb_gallery_grid .et_pb_gallery_item {
    width: 20%!important;
    clear: right!important;
}

For 6 Columns:

1
2
3
4
.et_pb_gallery_grid .et_pb_gallery_item {
    width: 16.66%!important;
    clear: right!important;
}
print