Center with position sticky

Good evening everyone I realise this
No description
16 Replies
Pat66
Pat66OPā€¢2w ago
this is my work :
No description
Pat66
Pat66OPā€¢2w ago
the problem is center the number inside the div my code:
<div class="first item">

<p><span class="number">1</span> </p>
<div class="curtain">

<div class="sub-title">
<span>Laboratory</span>
</div>
</div>

</div>
<div class="first item">

<p><span class="number">1</span> </p>
<div class="curtain">

<div class="sub-title">
<span>Laboratory</span>
</div>
</div>

</div>
the css:
.item{
flex-grow: 1;
overflow: hidden;
position: relative;
}

.first{
background-image: url('img/lab.jpg');
background-position: center;
background-size: cover;
}

.curtain{
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
background-color: white;
border-right: 3px solid black;
}



.number{
font-size: 32rem;
font-weight: 300;
position: sticky;
top: 50%;
left: 50%;
/*transform: translate(-50%,-50%);*/
z-index: 3;
display: block;
pointer-events: none;
}
.item{
flex-grow: 1;
overflow: hidden;
position: relative;
}

.first{
background-image: url('img/lab.jpg');
background-position: center;
background-size: cover;
}

.curtain{
position: absolute;
inset: 0;
display: flex;
flex-direction: column;
background-color: white;
border-right: 3px solid black;
}



.number{
font-size: 32rem;
font-weight: 300;
position: sticky;
top: 50%;
left: 50%;
/*transform: translate(-50%,-50%);*/
z-index: 3;
display: block;
pointer-events: none;
}
when I do
.number{
font-size: 32rem;
font-weight: 300;
position: sticky;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
z-index: 3;
display: block;
pointer-events: none;
}
.number{
font-size: 32rem;
font-weight: 300;
position: sticky;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
z-index: 3;
display: block;
pointer-events: none;
}
Pat66
Pat66OPā€¢2w ago
I get this
No description
Pat66
Pat66OPā€¢2w ago
thanks for any answer can help me to fix this problem
Pat66
Pat66OPā€¢2w ago
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pat66
Pat66OPā€¢2w ago
Pastebin
,::before,*::after{ box-sizing: border-box; margin: 0; p...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Chris Bolson
Chris Bolsonā€¢2w ago
What are you trying to achieve? Why are you using position:sticky?
Pat66
Pat66OPā€¢2w ago
Pat66
Pat66OPā€¢2w ago
this is what I want achieve
Chris Bolson
Chris Bolsonā€¢2w ago
As far as I can tell you don't need to use sticky for any of that šŸ¤”
Pat66
Pat66OPā€¢2w ago
I try fixed
Chris Bolson
Chris Bolsonā€¢2w ago
defintatly not fixed absolute is what you need here sticky is if you want the element to stay in place whilst it's parent scrolls (and is in view)
Pat66
Pat66OPā€¢2w ago
thanks problem solved tell me are you a new membe or the Chris I know here you get a work
Chris Bolson
Chris Bolsonā€¢2w ago
Iā€™m the same Chris as always šŸ˜†
Pat66
Pat66OPā€¢2w ago
WOW long time what news ?
Chris Bolson
Chris Bolsonā€¢2w ago
Not much really. Back-end coding during the day (work) and front-end fun in the evening (hobby) šŸ˜† I try to help out here when I can.

Did you find this page helpful?