Stacking containers with margin hidden issues

I really hope I am not asking too many questions… LOL…

here is my next annoying issues (which I am sure is due to my lack of CSS understanding). I have 4 containers with cards. Each card has a reveal element which when not hovered is hidden. This then creates margin so I am not able to stack the elements closer. on mobile I would like the four elements stacked with 10px of spacing. On larger screens they will be stacked two elements ontop of each other in a mosaic fashion.

I have tried playing with the position, they go all over the place and when I use the z-index it gets even crazier. all I am trying to achieve is overlap to get the elements on the y access closer without effecting the internal card elements.

thanks for any help that can be given.

its here for reference as to the answer…

I created a div class=“wrap” with positon relative

the cards are position absolute with a z-index. and an id Tag.

Screen Shot 2022-12-14 at 12.25.24 PM

Can never ask too many questions! Thats what the community is for! :wink:

I am having a hard time trying to figure out exactly what you are trying to do from the screenshot. Can you post your code here as well?

well I figured it out… however I am now trying to understand how to make this responsive.

I had to place the first column / card group on a different z index than the other three and work out the pixel placement to get them to stack since there is 80 px of margin on each card to hid the reveal content.

I am wondering if i need to have this layout show on mobile and then create another set of images configured for desk top and just hide and reveal based on screen size, or is there to reposition the columns to two high and two wide on desktop when they are z-indexed to stack for mobile…

CSS below - attached image shows the HTML


.newsCard {
position: relative;
width: auto;
height: 250px;
margin: 5rem auto;
background-color: #fff;
color:#fff;
overflow: hidden;
-webkit-box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
background-image: url("…/assets/mosaicImages/iceBergOne.jpg");
background-position: 50%;
background-size: cover;
}

.newsCaption {
position: absolute;
top: auto;
bottom: 0;
opacity: .6;
left: 0;
width: 100%;
height: 90%;
background-color: #000;
padding: 15px;
-webkit-transform: translateY(80%);
transform: translateY(80%);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transition: opacity 0.1s 0.3s, -webkit-transform 0.4s;
transition: opacity 0.1s 0.3s, -webkit-transform 0.4s;
transition: transform 0.4s, opacity 0.1s 0.3s;
transition: transform 0.4s, opacity 0.1s 0.3s, -webkit-transform 0.4s;
}

.newsCaption-title {
margin-top: 0px;
}

.newsCaption-content {
margin: 0;
}

.newsCaption-link {
color: #fff;
text-decoration: underline;
opacity: .8;
-webkit-transition-property: opacity;
transition-property: opacity;
-webkit-transition-duration: 0.15s;
transition-duration: 0.15s;
-webkit-transition-timing-function: cubic-bezier(0.39, 0.58, 0.57, 1);
transition-timing-function: cubic-bezier(0.39, 0.58, 0.57, 1);
}
.newsCaption-link:hover {
opacity: 0.65;
}

.news-Slide-up:hover .newsCaption {
opacity: .6;
-webkit-transform: translateY(0px);
transform: translateY(0px);
-webkit-transition: opacity 0.1s, -webkit-transform 0.4s;
transition: opacity 0.1s, -webkit-transform 0.4s;
transition: transform 0.4s, opacity 0.1s;
transition: transform 0.4s, opacity 0.1s, -webkit-transform 0.4s;
}

.wrap {
position: relative;
}

#d3 {
position: absolute;
top: 260px;
}

#d4 {
position: absolute;
top: 520px;
min-width: 410px;
z-index: 2;
}

#d5 {
position: absolute;
top: 780px;
z-index: 3;

looks like this on screen

I’m no CSS guru that’s for sure. But I don’t believe you can make something responsive that uses absolute positioning. You may be able to do it using media queries and assign different CSS per device size.

What are you trying to do there? Slide up the dark part, when the card is hovered?

yes correct.

Here’s a quick example you can play with, using some standard Bootstrap cards layout/structure and a photo similar to your example, taken by me :smiley:

The HTML:

    <div class="container">
        <div class="row">
            <div class="col-12 mb-3">
                <div class="card bg-dark text-white">
                    <img class="card-img" src="https://images.unsplash.com/photo-1659039807594-358e61bdfb5c?ixlib=rb-4.0.3&amp;ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&amp;auto=format&amp;fit=crop&amp;w=1740&amp;q=80">
                    <div class="card-img-overlay">
                        <h5 class="card-title">Card title</h5>
                        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                        <p class="card-text">Last updated 3 mins ago</p>
                    </div>
                </div>
            </div>
            <div class="col-12 mb-3">
                <div class="card bg-dark text-white">
                    <img class="card-img" src="https://images.unsplash.com/photo-1659039807594-358e61bdfb5c?ixlib=rb-4.0.3&amp;ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&amp;auto=format&amp;fit=crop&amp;w=1740&amp;q=80">
                    <div class="card-img-overlay">
                        <h5 class="card-title">Card title</h5>
                        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                        <p class="card-text">Last updated 3 mins ago</p>
                    </div>
                </div>
            </div>
            <div class="col-12 mb-3">
                <div class="card bg-dark text-white">
                    <img class="card-img" src="https://images.unsplash.com/photo-1659039807594-358e61bdfb5c?ixlib=rb-4.0.3&amp;ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&amp;auto=format&amp;fit=crop&amp;w=1740&amp;q=80">
                    <div class="card-img-overlay">
                        <h5 class="card-title">Card title</h5>
                        <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
                        <p class="card-text">Last updated 3 mins ago</p>
                    </div>
                </div>
            </div>
        </div>
    </div>

And the CSS:

.card {
    overflow-y: hidden;
}
.card-img-overlay {
    width: 100%;
    left: 0;
    top: auto;
    bottom: 0;
    -webkit-transform: translateY(calc(100% - 50px));
    transform: translateY(calc(100% - 50px));
    -webkit-transition: all 0.4s ease-in-out;
    transition: all 0.4s ease-in-out;
    background: rgba(0,0,0,0.4);

}
.card:hover .card-img-overlay {
    -webkit-transform: translateY(0);
    transform: translateY(0);
}

this is great. did you write this or use dynamic attributes or tools within Wappler?

I wrote this by hand actually. You can do most of the stuff in the design panel, except for the transform options.

Thats what I figured. The only change I will make other than applying style to text, etc. is not adding the image to the card. But apply the image to the background of the card.

thanks for the help

I just used one of the predefined card layouts, available in Wappler. But yes, you can probably adjust this and use a different approach.

thanks again, I find i use a combo of code and tools of wappler. So far a good experience.

1 Like

@Teodor would you mind helping me on one other issue I am having with my header navbar?

take a look at my issue on this thread I created. I know there is an easier way of doing this,

https://community.wappler.io/t/hid-nav-bar-at-certain-point-when-scrolling-down-page/46916/14

any help with the above issue would be appreciated. @Teodor