grid

How can we target the main-grid container grid lines for the grid item placed inside another grid container.(scale upwards)
No description
30 Replies
ProdJuan
ProdJuan4w ago
not sure why your existing class .text-image-section doesn't accomplish already.
Vandana
Vandana4w ago
Thanks for responding.it accomplishes a grid green lines...blue lines are the main container grid lines @ProdJuan ?
MarkBoots
MarkBoots4w ago
by making the .text-image-section a subgrid that spans over columns: 1 to -1
.text-image-section{
grid-column: 1/-1;
display: grid;
grid-template-columns: subgrid;
}
.text-image-section{
grid-column: 1/-1;
display: grid;
grid-template-columns: subgrid;
}
Vandana
Vandana4w ago
since i made the text-image-section a nested grid,now i am unable to position the scenary image (img-four) inside the nested grid because of the main grid line its occuping
No description
Vandana
Vandana4w ago
there is no clean CSS method for moving nested elements into the main grid container.???
MarkBoots
MarkBoots4w ago
this is the way to nest grid. don't know what you think is not clean about it ah, i see what you mean. in this case you don't want to span from 1 to -1. you can remove that line i thought you wanted it to be the full width
Vandana
Vandana4w ago
now i need to move that car image of out the nest grid and span somewhere in the main grid
No description
Vandana
Vandana4w ago
This is my question there is no clean CSS method for moving nested elements into the main grid container.??? If it is there then how?
MarkBoots
MarkBoots4w ago
ohw, no, indeed. But, why put it in that section in the first place (html)?
Vandana
Vandana4w ago
That is the requirement as per the design I had designed for mobile devices that is why now large screen sizes is becoming messy
MarkBoots
MarkBoots4w ago
no, can't see a way. either you take it out of the html (level up), or you put the mountain image in it, you can not do half/half.
Vandana
Vandana4w ago
Not getting what do you mean?
MarkBoots
MarkBoots4w ago
you have 2 elements in text-image-section, but you want 1 item to be taken out of it. maybe, you can get around with it by setting .text-image-section {display: contents} , then the 2 elements will be childs directly of the main container. bit hard to tell without live code
Vandana
Vandana4w ago
yes ,something works.. with display:contents when do we use this property??
MarkBoots
MarkBoots4w ago
i did use this before we had subgrid. or sometimes it is nice to just group things (just for clearness) but not wanting it to be grouped (it will just ignore that_
Vandana
Vandana4w ago
I have mentioned the code in Nested Grid post i have tagged you so that you can go through unable to catch this point could you please explain?
MarkBoots
MarkBoots4w ago
<div>hello</div>
<div style="display: contents">
<div>world</div>
</div>
<div>hello</div>
<div style="display: contents">
<div>world</div>
</div>
here the second div will only show the contents, not the div itself. so hello and world are threated as direct siblings of eachother
<div>hello</div>
<div>world</div>
<div>hello</div>
<div>world</div>
ProdJuan
ProdJuan4w ago
cool, so you get the benefit of the group but w/o the structure insertion. neat!
MarkBoots
MarkBoots4w ago
indeed it will show up in the html ofcourse, but it's not threated as such so in media queries you can change it if you need
Vandana
Vandana4w ago
Great explaination!! Got it Thanks @MarkBoots @ProdJuan things are working as expected due to display:contents.Took 15 days to figure it out One more doubt. should the media queries min-width or max-width be in px or rem ?
MarkBoots
MarkBoots4w ago
probably you would like to use px. screenwidths/monitor sizes are fixed while rem can be a user specified value
Vandana
Vandana4w ago
Ya but then lot many posts do recommend to use rem only
MarkBoots
MarkBoots4w ago
for typography yes. but a 1920 screen will be that, won't be changed by font size
Vandana
Vandana4w ago
The Surprising Truth About Pixels and Accessibility
“Should I use pixels or rems?”. In this comprehensive blog post, we'll answer this question once and for all. You'll learn about the accessibility implications, and how to determine the best unit to use in any scenario.
Vandana
Vandana4w ago
Go through the media queries section in this post
MarkBoots
MarkBoots4w ago
yea, there are pro's and cons to this. it depends on the project i guess
Vandana
Vandana4w ago
What do you suggest ?
MarkBoots
MarkBoots4w ago
if it is a one column layout .no side bars or such (those can vary in width due to rem font-size), I think px is okay. but that's personal pref
Vandana
Vandana4w ago
OK thanks for the help and information! @MarkBoots please review the code for the deployed link https://assortedgridrwd.netlify.app and let me know your feedback on this.Would be a great help!
Vandana
Vandana4w ago
Stephen Lee
CodePen
Assorted cards & images (CSS Grid + BEM)
A card layout with various sizes, containing images and/or text. Using BEM to try to keep the code organized (and to help keep the design consistent)....