Is there a correct way to copy these containers?
Sorry for that bad title, I created this basic container I wanted to know is there a correct way to copy the containers or would I have to make separate containers with the same styling?
46 Replies
What im trying to recreate is this
But with two more containers under so a total of 4 containers
im confused
are you just wanting 2 columns.
each column has 2 containers sitting there in a stack. (The contents of 1 container is visible as it is sitting there on top of the other one)
So if you look in the image I sent you there's two containers side by side I wanted to recreate that with two more containers under them
Could I just make two seperate divs that house two containers and edit it like that?
i dont see why not?
youd just need to either position them using grid or position absolute them
if u r using vanila html then u do need to have 2 different containers for 2 different card
basically u have manually add these elements to your html doc
for styling ofc u don't need to style them individually, they're structurally and desingwise sane so u can give them same class and stuff to give the same styling to both these cards
now if u have 10 cards ,u still need to do it 10 times manually for html
reason being html files r static files
now u can use frameworks like astro or pre-processors like pug that introduces js functionalities within html giving it some dynamistic behaviour
additionally, u can use simple js as well
Im not really understanding and sadly I dont know much JS right now
See I got it done like this
The lining is bad when I copy and paste ignore it
That's all the CSS code for it
But sadly I cant figure out a way to make them go on top one another when the screen continues to shrink
For example The "Skills" looks like this full screen
When the screen becomes smaller it looks like this
you would be best to create a project-container--wrapper div and then position the boxes within the wrapper
either position absolute;
or display grid;
and set the project-containers to the same column and row
but this is just a solution to your question of how to position the containers on top of each other.
I am still at a loss as to why you are doing this
For the projects portion of my page I'd like to have four containers that show the images of the project like this
But since I'd like to add two more projects I want to have them stacked so two projects on top and two under
Just to make sure so I dont go about this wrong how can I set my project containers to the same column and row?
Quick question, If you have two seperate containers with two divs in each how come there are only two boxes shown?
because you asked for them to be stacked as I clarified above
if you didnt want them stacked like that, just create 2 rows and dont specify anything for the grid items
The code I had originally written caused my boxes to look like this when i shrinked the browser as much as possible would it be possible to have all the containers stacked on top of one another in one single row
thats what Im having a hard time understanding
That's the code I had written
oh, now I understand
Im sorry if Im explaining it bad I know I am lol
any reason why you had project containers?
I still haven't fully managed to explain code well I just sound goofy
Honestly I really liked the way the original idea was from the img. It was nice and simple in my opinion, he had the laptop/phone with his project displayed on them and he had a small description stating what the project was and then a redirect button.
so which one are you treating your project-boxes like?
Number two
so thats super simple
you just need to set a width on the container
and make it so that you can use that flex that you had earlier
Simple bro, use grid and give z-index to the border. By using grid it will become more simpler, when you squeeze the size of the screen the container will automatically get wrap and also it will be responsive.
give the projects-wrapper a margin-inline to keep it in the middle of the page but otherwise that will end with 2 boxes side by side but will wrap as needed to a column of 4
just margin-inline?
so unsure why youd want to give anything a z-index when I dont believe that a stacking context would be created like that but 🤷
there added a margin inline
So should it always stay stacked on top of one another?
you could 100% use grid here instead of flex. but you had flex in your original example code so I have gone with that for simplicity's sake
( I zoomed out)
Honestlty looking onto to it wouldnt grid have been the better option?
yup.
I wanna quickly say somethin because the code looks good just not 100% (sorry once again)
when I have made the browser screen smaller it looks perfect but when I full size the browser it still stuck like this
these are standalone examples as a quick fix.
if you want anything more, youd need to give us something where it would be used as a whole rather than copy pastaing code when it definitely wont work in every case
chances are the container is being constrained somehow, without seeing everything in the larger project it would be impssible to give more exacts
I can show you the entire code on a codepen if you'd like? I'd never really want to copy and paste code I just need to understand what's happenin so I can know how to do it
Yeah, by seeing his code If he use background image in screen then text inside the container will not be clickable, in that z-index will manage it
Bishal a zindex requires the containing element to have a position other than static.
I don't believe display grid will set up the context by itself
I'm out picking something up now.
But you have some basic solutions I believe you should be able to set the widths of the project boxes and have them either wrap with flex or auto flow in grid
I swear I’ve heard KPow say flex or grid allows zindex to work without also declaring a position but maybe I’m misremembering a detail
It wouldn't surprise me considering everything else that was shoved into their specs
you're talking about stacking contexts, they are created in flex and grid contexts: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_positioned_layout/Understanding_z-index/Stacking_context
MDN Web Docs
Stacking context - CSS: Cascading Style Sheets | MDN
Stacking context is a three-dimensional conceptualization of HTML elements along an imaginary z-axis relative to the user, who is assumed to be facing the viewport or the webpage. HTML elements occupy this space in priority order based on element attributes.
A stacking context is formed, anywhere in the document, by any element in the following scenarios: [...] * Element with a position value absolute or relative and z-index value other than auto. [...] * Element that is a child of a flex container, with z-index value other than auto. * Element that is a child of a grid container, with z-index value other than auto.(the entire article is a good read, stacking context is really good to understand)
My understanding of stacking context is sub par , especially how transforms and opacity effects it too.
definitely same