Does anyone know what could be the problem here?
Not without seeing the code.
Screenshots are of limited use. They show us the problem you're trying to solve.
Code shows us why the problem exists.
Best if you upload your page to the web (even temporary webspace) and post a link to the page here so we can view the page in our browsers.