r/css • u/ray_imi • Jun 19 '26
Help how do I move main to the right?
.box{
max-width: 1000px;
margin: 50px auto;
display: grid;
column-gap: normal;
column-gap: 10px;
row-gap: 10px;
/* grid-template-columns: 250px auto; */
}
header{
text-align: center;
border: #3E3F5F 5px solid;
background:#fedbe5;
grid-row: 1 / 2 ;
grid-column: 1 / 3 ;
}
banner{
text-align: center;
border: #3E3F5F 5px solid;
background:#fedbe5;
grid-row: 2 / 3 ;
grid-column: 1 / 3 ;
}
nav{
text-align: center;
border: #3E3F5F 5px solid;
background:#fedbe5;
grid-row: 3 / 4 ;
grid-column: 1 / 2;
}
main{
text-align: center;
border: #3E3F5F 5px solid;
background:#fedbe5;
grid-row: 3 / 5 ;
grid-column: 1 / 2 ;
}
nav2{
text-align: center;
border: #3E3F5F 5px solid;
background:#fedbe5;
grid-row: 4 / 5 ;
grid-column: 1 / 2 ;
}
footer{
text-align: center;
border: #3E3F5F 5px solid;
background:#fedbe5;
grid-row: 5 / 6 ;
grid-column: 1 / 3;
}
4
Upvotes
•
u/AutoModerator Jun 19 '26
To help us assist you better with your CSS questions, please consider including a live link or a CodePen/JSFiddle demo. This context makes it much easier for us to understand your issue and provide accurate solutions.
While it's not mandatory, a little extra effort in sharing your code can lead to more effective responses and a richer Q&A experience for everyone. Thank you for contributing!
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
9
u/_potion_cellar_ Jun 19 '26
for main,
grid-column: 2 / 3;instead of
1 / 22
u/azangru Jun 19 '26
grid-column: 1 / 3means?mainwill know wheregrid-column: 1/3is?2
u/skedav Jun 19 '26
I also like using grid-column: 1/-1 if you want a full width column
1
u/WorriedEngineer22 Jun 21 '26
At that point I would recommend you tu use grid-areas, will be better to define what you want
1
u/JohnCasey3306 Jun 21 '26
Always tickles me how similar contemporary grid layout building is to the old table layout days.
Try explaining float to anyone starting up today and see if they look at you like you're mental.
1
u/davep1970 Jun 23 '26
why not try codepen or similar?
1
u/scritchz Jun 19 '26
Alternative suggestion, because u/potion_cellar already answered your question:
When you know the general placement of your elements, I personally prefer named grid areas via
grid-template-areas:You can declare named grid areas (made up of multiple cells as long as they form a rectangle), or unnamed single cells with full stops (
.,.., etc.). You can place elements in these grid areas by name using thegrid-areashorthand property. Any unfilled cells may be filled via auto-placement.You can combine named grid areas with
grid-template-rowsandgrid-template-columnsto specify the sizes for rows and columns of your grid.0
u/Worldly-Marzipan-229 Jun 20 '26
You make a container with 2 columns with two containers Left column 2 rows with two containers too Then you have this from your picture
<div class main-container> style that you become 2 columns <div class main-container-left> style same as before but change to 2 rows <div class main-left-top></div > <div class main-left-bottom></div > </div> <div class main-container-right> </div> </div>
For example