The upper section of my website vanishes as I adjust the vertical size

Looking for some help with creating a responsive log in page for a college. I'm encountering an issue where the logo and top part of the page disappear when resizing the window vertically.

Currently, I am working on designing for an iPhone 7 using Google Chrome's dev tools for reference. When testing the website on my Huawei phone, tapping the password field causes the keyboard to push the page up and partially hide the logo, which doesn't occur on my iPhone.

I suspect the problem lies within my div elements. Apologies if this is a basic question, as I am still a beginner in web development.

For more context, here is the link to the website:

body
{
margin: 0;
}

img
{
max-width: 300px;
position: absolute;
top: 60px;
left: 37px;
z-index: 1;

}

.container
{
width: 375px;
height: 667px;
background-color: white;
margin: auto;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
font-family: Georgia;
}

.form-back
{
width: 200px;
background-color: white;
z-index: 1;
margin: 0 auto;
padding: 45px;
position: absolute;
top: 80%;
left: 50%;
transform: translate(-50%, -80%);
text-align: center;
font-size: 18px;
}


input[type=text], input[type=password]
{
width: 100%;
padding: 10px;
margin: 8px 0px 8px;
border: solid 1px #aaa;
border-radius: 4px;
}

button
{
width: 100%;
height: 50px;
border: none;
border-radius: 30px;
border-color: white;
background-color: #e52791;
font-family: Georgia;
transition: background-color 0.7s ease-out;
}

button:hover
{
background-color: #02356a;
color: white;
transition: background-color 0.7s ease;
}

.submit
{
position: relative;
top: 30px;
}

::placeholder
{
font-family: georgia;
}
<div class="container">
<div class="img"><img src="logo.jpg"></div>

<div class="form-back">
<form action="message.html" onsubmit="return validation()">
<div>
<label for="accountNum">Metric Number</label><br>
<input type="text" id="accountNum" name="accountNum" placeholder="Metric Number..."><br>
</div>

<div>
<label for="surname">Password:</label><br>
<input type="password" id="surname" name="surname" placeholder="Password..."><br>
</div>

<div class="submit">
<button type="submit">Log In</button>
</div>
</div>
</div>

Answer №1

After reviewing your code, it seems that the issue you are encountering may be related to the use of absolute positioning in multiple elements. I have made some adjustments to your CSS code and provided a snippet below for you to replace. Hopefully, by implementing these changes, your problem will be resolved:

         body
          {
              margin: 0;
          }

          img
          {
              width: 100%;
              max-width: 300px;
              z-index: 1;
              margin: 0 auto;
          }

          .container
          {
              margin: 0 auto;
              font-family: Georgia;
              text-align: center;
          }

          .form-back
          {
              width: 100%;
              
              background:transparent;
              margin: 0 auto;
              padding: 45px;
              text-align: center;
              font-size: 18px;
          }


          input[type=text], input[type=password]
          {
              width: 100%;
              padding: 10px;
              margin: 8px 0px 8px;
              border: solid 1px #aaa; 
              border-radius: 4px;
          }

          button
          {
              width: 100%;
              height: 50px;
              border: none;
              border-radius: 30px;
              border-color: white;
              background-color: #e52791;
              font-family: Georgia;
              transition: background-color 0.7s ease-out;
          }

          button:hover
          {
              background-color: #02356a;
              color: white;
              transition: background-color 0.7s ease;
          }

          .submit
          {
              position: relative;
              top: 30px;
          }

          ::placeholder
          {
              font-family: georgia;
          }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

<div class="container">
    <div class="img"><img src="https://borislav1333.000webhostapp.com/logo.jpg"></div>

    <div class="form-back">
        <form action="message.html" onsubmit="return validation()">
                <div>
                    <label for="accountNum">Metric Number</label><br>
                    <input type="text" id="accountNum" name="accountNum" placeholder="Metric Number..."><br>
                </div>

                <div>
                    <label for="surname">Password:</label><br>
                    <input type="password" id="surname" name="surname" placeholder="Password..."><br>
                </div>

                <div class="submit">
                    <button type="submit">Log In</button>
                </div>
              </form>
    </div>
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Ways to transition between divs using clickable buttons

I have a coding challenge where I need to implement two panels. The lower panel consists of three buttons and upon clicking each button, different data should load in the upper panel. For example, when button 1 is clicked, divs 1.1, 1.2, and 1.3 should sl ...

Utilizing margins in CSS for various div elements

Update: I have included Javascript and Masonry tags in my project. Despite having modules of the same size, I am exploring how masonry can assist me. However, I find it a bit puzzling at the moment as I am not aiming to align elements of different sizes. I ...

Create a dynamic HTML design with a resizable left panel and a static right panel. The left panel should not wrap text and display ellipsis if necessary

I am looking to display items in a list with a specific format: |Name | Some other val1| |Very very long no wrap line that...| Some other val2| The right side needs to have a fixed width. The left side should fill al ...

Safari IOS presents a display issue when using fx-layout="column" for Flex layout

We are currently utilizing Angular for the front-end with fx-layout API for responsiveness. Whenever we employ fxLayout="column", all elements collapse and appear to have no height. What is the recommended approach when using fx-layout/flex to address th ...

What is the best way to anchor floating labels in React while incorporating Tailwind CSS?

I am currently working on developing a registration form using React and Tailwind CSS. As part of this project, I have implemented a feature where the label slides up when an input form is focused. Everything seems to be working fine up to this point. Howe ...

Choose an identifier from a CSS class

I've been experimenting with a code pen that I stumbled upon: http://codepen.io/surjithctly/pen/pLDwe When I encase the checkbox in a div with the class "mynav," it stops functioning as intended. How do I implement the specified styling for the check ...

Tips for positioning text alongside ICONS using CSS

Is there a way to align the text in the second row with the text in the first line? Here is the URL for my website: https://stgbusiness.wpengine.com/ And here is the code: <img src="https://stgbusiness.wpengine.com/wp-content/uploads/2021/10/modu ...

There seems to be some odd behavior with the page design

When you visit my website at lookaroundyou.net and select USA (where there are more videos than any other section), the entire layout of the website transforms. Can anyone explain why this sudden change occurs? ...

Unable to get CSS Filter to function properly in Firefox

I'm having trouble with the CSS filter on my Firefox (15.0) browser. Here is the HTML code: <div class="google"> <img src="https://www.google.com/images/srpr/logo3w.png"> </div> And here is the CSS code: .google{ -moz ...

Unable to trigger click event after slider is modified

One of the tasks at hand is to change the image/div margins in a slider upon click. Change the image margin in the slider Adjust text opacity in the top section of the slider Initially, the code operates as intended when the page first loads for the firs ...

HTML and CSS: Centering elements inside div containers

Is it possible to align elements within a </div> using the align attribute? For example, as shown in the image below: e1:align="top" e2:align="right" e3:align="bottom" e4:align="left" EDIT: This query is purely for self-learning purposes in HTML ...

Incorrect element being returned by click event

Seeking assistance with creating a card that rotates upon clicking. The current setup is functional, however, I am aiming to utilize the onclick event to append the 'is-flipped' class to the classlist of div.card. Upon inspecting the event throug ...

Two adjacent divs, flexible with maximum width

I want to create two side-by-side DIVs, with the left one always containing text and the right one possibly being empty. If the right DIV contains text ... the width of the left DIV should adjust to match the text width, but only up to 50% of the parent D ...

Bootstrap 4 has an enlarged input field when compared to the select input

I am facing an issue with the size of my select field, which appears larger than my two input fields in Bootstrap 4.3. Can anyone provide guidance on how to make the select field match the size of the input fields? Your assistance would be greatly apprecia ...

Designing exquisite button navigation

Hey everyone, I'm currently working on creating a circular button navigation for my website. I want to have 4 buttons, each with a different color, and I want them to glow when the user hovers over them. So far, this is what I have in my HTML: HTML: ...

Plugin that collapses dropdown menus when the mouse hovers over them, powered by jQuery

My webpage has a simple set of links, and one of them triggers a dropdown menu to appear on mouseover (refer to the image below). The dropdown submenu becomes visible when the link "How fast is it?" is hovered over, and remains fixed in place due to the di ...

The iPhone 6 Plus's Safari browser, when in landscape mode, displays multiple tabs open at once. Additionally, when a Bootstrap modal

Encountering an issue with the bootstrap modal on iPhone Safari 6+ in landscape mode. This glitch only happens when using multiple tabs on the browser. Follow these steps to replicate the problem: 1) Visit http://getbootstrap.com/javascript/ on your iP ...

Create paper "cut" borders using HTML canvas or pseudo-elements

As a designer with a penchant for pain, I am striving to achieve an "art nouveau" aesthetic on paper for my NextJS project with MUI as the main design solution. Despite the abundance of CSS in the background, I am faced with the challenge of creating inner ...

Troubleshoot: Difficulty with accessing nested tag name using getElementsByTagName

I'm currently working with a div that contains a table and its data pulled from a database. <div id="content"> <table> <tbody> <tr> <th class="header" colspan="2">Food items include:</th> </tr> ...

Issue with Bootstrap's pull-right class causing elements to overlap

I need help positioning a single button above a list, with the button to the right. Whenever I try using the pull-right class on the button (or its containing div), the button ends up being covered by the list. <div> <div class="pull-right"& ...