0

I have many number of div elements and in the last div element i used position: fixed; for not to change the position of the element while scrolling.

So the issue is some of the top div elements gets overlapped by the bottom div element because it has css like this.

#div1 {
  position: fixed;
  background: blue;
  font-size: 50px;
  bottom: 0;
}

Fiddle Link attached

htoniv
  • 1,658
  • 21
  • 40

3 Answers3

1

Add some padding on the parent element, in this case the <body>:

body {
  padding-bottom: 65px;
}

#div1 {
  position: fixed;
  background: blue;
  font-size: 50px;
  bottom: 0;
}
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a</div>
<div>a19</div>
<div>a20</div>
<div>a21</div>
<div>a22</div>
<div>a23</div>
<div>lastdiv</div>

<div id="div1">
  Example
</div>
Jos van Weesel
  • 2,128
  • 2
  • 12
  • 27
0

You can try adding z-index to it. Try this code.

#div1 {
  position: fixed;
  background: blue;
  font-size: 50px;
  bottom: 0;
  z-index: 99;
}
Aryan Twanju
  • 2,464
  • 1
  • 9
  • 12
  • It is woring without z-index also.. thanks. Pls post if there is anyother solution. thans in advacne. – htoniv May 15 '18 at 08:15
0

First : for access to last div , you dont need id

Replace this code :

div:last-child {
  position: fixed;
  background: blue;
  font-size: 50px;
  bottom: 0;
}
div:nth-last-child(2) {
  height:75px;
}
Mohammad Esmaeili
  • 155
  • 2
  • 2
  • 12