CSS behaving abnormally on mobile devices

I'm trying to center my login and register panel on the screen. It looks good when viewed from a computer or using the inspect menu to simulate mobile devices. However, when I try to view it on my actual mobile device, this is what I see: image and this is how it appears in the inspect menu on the computer: image2

Here is the code I am using:

<div class="wrapper2" style="font-size: 24px;">
        <h2>Login</h2>
        <p style="padding-bottom: 30px;">Please fill out the following fields.</p>
        <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
          <div class="form-group <?php echo (!empty($username_err)) ? 'has-error' : ''; ?>">
            <label>Username/Email address</label>
            <input type="text" name="username" class="form-control" value="<?php echo $username; ?>">
            <span class="help-block" style="color: red;"><?php echo $username_err; ?></span>
          </div>
          <div class="form-group <?php echo (!empty($password_err)) ? 'has-error' : ''; ?>">
            <label>Password</label>
            <input type="password" name="password" class="form-control">
            <span class="help-block" style="color: red;"><?php echo $password_err; ?></span>
          </div>
          <div class="form-group">
            <input type="submit" class="btn btn-primary" value="Login">
          </div>
          <div class="plus" style="font-size: 18px;">
          <p>Not registered yet? <a href="register.php">Register</a></p>
          <p>Forgot your password? <a href="password-reminder.php">Password Reminder</a></p>
          </div>
        </form>
      </div>

Here is the CSS:

.wrapper2{
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font: 18px sans-serif;
  text-align: center;
}

Answer №1

Based on the CSS of a div with the class .wrapper2, it appears that you are attempting to vertically center this div within its parent div with the class .main-panel. I reviewed the live link you provided and found that the height is set to 100% (presumably matching the device viewport). To achieve vertical centering, you can add min-height: 100vh; to this div's CSS, like so:

.perfect-scrollbar-on .main-panel {
    height: 100%;
    max-height: 100%;
    min-height: 100vh;
}

I hope this solution resolves your issue.

Answer №2

After investigating, it appears that the issue may stem from the css top property. By deactivating this property, the problem on your mobile device seems to be resolved. I hope this information proves helpful to you.https://i.sstatic.net/2FGMK.png

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

retrieve the chosen option from the dropdown menu

Whenever I try to display the input type based on the selection from a select element, I encounter an issue Here is the select element within my view: <select id="type" name="type_id" class="form-control" required> @foreach($type as $row) & ...

Guidelines for redirecting to ensure the presence of an HTML page within a directory URL

In my folder named /topicA/, I have various subtopics like /topicA/subtopic1.html, /topicA/subtopic2.html, and /topicA/subtopic3.html. I also wanted to create a /topicA.html page, but I'm having trouble getting the .htaccess file to function properly ...

Combining Javascript and Django for a powerful web development solution

Having trouble setting up JS on my Django web app, despite reading through the documentation and previous queries. Using the Django dev server with the following file structure: mysite/ __init__.py MySiteDB manage.py settings.py ...

Taking on The Notch: How Can I Improve?

I'm currently working on a website for my friend's bar, but I'm facing an issue with Chrome where the content can't push past the "notch". Interestingly, Safari displays it fine on mobile, while Chrome has this unsightly white space. I ...

This piece of code is causing my browser to lag

I am encountering an issue with fetching and adding values from a weather API to my HTML elements. My goal is to display the hourly forecast for today, starting from the current hour until midnight of the next day. In order to optimize space, I implemente ...

What is the best way to move between websites or pages without having to reload the current page using a selector?

Have you ever wondered how to create a webpage where users can navigate to other websites or pages without seeing their address, simply by selecting from a drop-down menu? Take a look at this example. Another similar example can be found here. When visit ...

Fading CSS Background Transition with Responsive Design

One generous member of our online community shared a CSS rollover code that is "fluid" and can adapt to different browser sizes. The code is provided below, along with a link to JsFiddle: CSS .container { width: 100%; height: 300px; backgroun ...

Including React components in my HTML documents

I have developed a node.js server using express and am rendering an html page with jsx code embedded. The server is running smoothly, but I am encountering difficulties when trying to import other jsx components into my html file to utilize them in my main ...

Experiencing an issue where the canvas element fails to render on mobile Chrome browser,

I've encountered an issue with a script that draws a canvas based on the background color of an image. The image is loaded dynamically from a database using PHP. The responsive functionality works fine on mobile Safari, but not on Chrome. When the re ...

Position a button freely on the grid layout of bootstrap4

I need help creating a sidebar in Bootstrap 4 with a floating arrow button to collapse it, similar to this example. Currently, I'm using a `container-fluid` and dividing the row into a 2-8-2 layout for left sidebar, main content, and right sidebar. I ...

Using React Native's stylesheet to apply multiple values in a CSS statement

Here's a scenario to help clarify my question: Imagine I want to add margin to an element in the following way: const myView = () => <View style={styles.viewStyle}></View> const styles = StyleSheet.create({ viewStyle: { margin: ...

Solving the mystery of background color in CSS for heading/title div

I am facing an issue with the title div setup where the red background is not applied when only the leftmost div has content. Despite the 'title' div having content, the background remains white. Can anyone suggest why this might be happening? H ...

Challenges with transitions and transformations across different web browsers

I've encountered some difficulties while working on my new website. The mobile navigation menu is supposed to appear when the browser window is below 940px wide. It functions properly on Chrome and other webkit browsers, but in Firefox and IE, the tr ...

Click to dynamically toggle classes with jQuery

I am trying to apply a class called 'select' when I click on a paragraph tag. However, the code I have written doesn't seem to be working. Can someone please provide some suggestions? Here is the code: <style type="text/css"> #el ...

Enhancing the Appearance in Internet Explorer 7

Recently, I decided to check my client's new website on my BrowserStack account. I'm not very experienced in developing for older browsers, but I wanted to make sure the website was at least viewable on them. I tested it on Windows XP with IE 7. ...

Having difficulty triggering the onchange event for a combo box programmatically in IE using JavaScript

I need to dynamically trigger the onchange function when the user changes the value of another combo box. Here's my code: HTML <select name="vbitratecontrol0" id="combo1" onchange="set()"> <option value="0">None</option> ...

How can I wrap text in Angular for better readability?

I've created a calendar in my code that displays events for each day. However, some event descriptions are too long and get cut off on the display. Even after attempting to use Word Wrap, I still can't see the full text of these events unless I c ...

The Datatable feature is malfunctioning, unable to function properly with Javascript and JQuery

As a novice in the world of jquery/javascript, I find myself struggling with what may seem like an obvious issue. Despite following tutorials closely (the code for the problematic section can be found at jsfiddle.net/wqbd6qeL), I am unable to get it to wor ...

Should you construct a fresh element using JavaScript, or opt to reveal a concealed one using CSS?

What are the benefits of using the following approach: var target = document.getElementById( "target" ); var newElement = document.createElement( "div" ); $( target ).after( newElement ); compared to just hiding the newElement div with CSS and showing ...

Fade out a dynamically loaded content block using jQuery

I am currently developing a small app and encountering issues with deleting (fading out) dynamically loaded div elements using jQuery. The problem occurs when adding a new content box. If the page is reloaded and the content box is rendered normally (from ...