July 2, 20206 yr i really try and try to make margin for grid area elements ( 4 pic ) i want to make margin right and margin left with maintaining of centering of elements i want the 4 pic still in center with left margin and right margin ! code of html <div class="image"> <img class="one" src="images/pic03.jpg" alt=""> <img class="two" src="images/pic04.jpg" alt=""> <img class="three" src="images/pic01.jpg" alt=""> <img class="four" src="images/pic05.jpg" alt=""> </div> code of css .image { min-width: 100%; display: grid; grid-template-areas: "o th" "t f" ; } .image .one { display: block; margin-left: auto; margin-right: auto; width: 100%; grid-area: o; } .image .two { display: block; margin-left: auto; margin-right: auto; width: 100%; grid-area: t; } .image .three { display: block; margin-left: auto; margin-right: auto; width: 100%; grid-area: th; } .image .four { display: block; margin-left: auto; margin-right: auto; width: 100%; grid-area: f; }
July 2, 20206 yr You should be able to center by adding justify-content: center; to the .image class and adding whatever margins you need. You might be able to use grid-gap instead of margin to space items out too.
July 2, 20206 yr Author i write the code grid gap but i want left and right margin to the section of the images not the images
Create an account or sign in to comment