Reputation: 11
I am creating a new portfolio site. I am using wordpress and coding in a custom html block.
I want to use a <div class="hovertrigger" id="hovertrigger1"></div>
as border for another <div class="wp-block-gmedia-gallery gmedia-shortcode" id="gallery1">[gmedia id=13]</div>
.
In other words, "#gmedia-gallery should be always below .hovertrigger, ideally with a little space.
If I change the html hierarchie my layered divs gets broken. Right now I am using a minus margin with a fixed pixel distance. I want it to be correctly responsive to screen size.
my site: http://lilphil.de/ my current code:
.container {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(5, 1fr);
grid-column-gap: 0px;
grid-row-gap: 0px;
blend-mode: lighten;
z-index: 100;
pointer-events: none;
position: relative;
mix-blend-mode: lighten;
}
.logo {
grid-area: 1 / 1 / 6 / 5;
text-align: center;
z-index: 400;
opacity: 1;
pointer-events: none;
height: 100%;
width: 100%;
}
.hovertrigger {
z-index: 1000;
grid-area: 1 / 1 / 4 / 5;
width: 100%;
height: 50%;
pointer-events: auto;
background: none;
}
.logoanim {
grid-area: 1 / 1 / 6 / 5;
text-align: center;
z-index: 500;
opacity: 0;
pointer-events: none;
height: 100%;
width: 100%;
}
#gallery1 {
margin-top: -590px;
}
#hovertrigger1:hover~.logoanim {
opacity: 1;
}
#hovertrigger1:hover~div.logo {
opacity: 0
}
.wp-image-536 {
height: 100%;
width: 100%;
object-fit: cover;
}
.wp-image-587 {
height: 100%;
width: 100%;
object-fit: cover;
}
<div class="container">
<div class="hovertrigger" id="hovertrigger1"></div>
<div class="logoanim" id="logoanim1"><img src="http://lilphil.de/wp-content/uploads/2022/08/Comp-1.gif" alt="" class="wp-image-536"></div>
<div class="logo" id="logo1"><img src="http://lilphil.de/wp-content/uploads/2022/08/Comp1_00000.jpg" alt="" class="wp-image-587"></div>
</div>
<div class="wp-block-gmedia-gallery gmedia-shortcode" id="gallery1">[gmedia id=13]</div>
I really hope I could explain my problem.
Upvotes: 0
Views: 84
Reputation: 11
It needs another div in the HTML Code, so it does look like this:
<div>
</div>
<div class="container">
<div class="hovertrigger" id="hovertrigger1"></div>
<div class="logoanim" id="logoanim1"><img src="http://lilphil.de/wp-content/uploads/2022/08/Comp-1.gif" alt="" class="wp-image-536"></div>
<div class="logo" id="logo1"><img src="http://lilphil.de/wp-content/uploads/2022/08/Comp1_00000.jpg" alt="" class="wp-image-587"></div>
</div>
<div class="wp-block-gmedia-gallery gmedia-shortcode" id="gallery1">[gmedia id=13]</div>
Upvotes: 0
Reputation: 91
If you haven't tried it already, you may find it useful to use a grid view layout when designing your web page. Basically, if you divide the entire page into a grid with columns and rows (sized using relative units, like percentages), you can place #gallery1 in the row beneath #hovertrigger1. That way, your divs will always be layered regardless of screen size.
Also, if possible, I recommend using relative units instead of pixels so that your webpage elements stay proportioned across different screen dimensions and pixel resolutions.
Upvotes: 0
Reputation: 11
Well I tried some things and I think the easiest way is to change
#gallery1 {
margin-top: -590px;
}
to
#gallery1 {
margin-top: -38%;
}
as the other divs already scale on percentages.
Upvotes: 1