Elements shifting positions based on the size of the window

I am facing an issue with positioning the register form on my website. I want it to be fixed at the bottom-right corner of the window, without reaching the top. Although I managed to achieve this, the problem arises when the screen resolution changes. For instance, on a 1920x monitor, the button is not visible and only the email field can be seen. How can I ensure that the form stays in the same position regardless of the resolution?

Despite searching online for solutions, I couldn't find anything that works. I apologize if this seems like a beginner question, but this has been bothering me for some time now. I hope to find a reliable solution that I can use in the future as well.

This is how I envision the correct placement:

https://i.sstatic.net/is4F6.jpg

However, the form appears incorrectly on other monitors: https://i.sstatic.net/yilZE.jpg

Code:

    <!DOCTYPE html>
<html>
... (code snippet continues)

CSS Code:

html,body {
    overflow: auto;
}
... (CSS code snippet continues)

The current display on my monitor is causing confusion: https://i.sstatic.net/j4Klw.jpg

Here is what it looks like on a 1920x1080 screen: https://i.sstatic.net/QtbTT.jpg

I experimented with using pixels and percentages, but unfortunately, the results were consistent and disappointing. Help! I'm losing patience...

Now that I have resolved the previous issue, I am encountering another problem - the icons are not maintaining their positions consistently across screens. https://i.sstatic.net/ezSC8.jpg

On higher resolutions, the alignment of the icons gets distorted: https://i.sstatic.net/mvKFn.jpg

Div Code:

<div id="main">
    <form id="loginform" action="/action_page.php">
        <label class="usernam" for="username">Username</label>
        <input type="text" id="username" name="username" placeholder="Insert your username...">
        <img id="userimg" src="http://icons.iconarchive.com/icons/custom-icon-design/pretty-office-2/24/man-icon.png"/>

        ... (div code snippet continues)
    </form>
</div>

CSS:

#userimg {
    position: absolute;
    top: 9%;
    right: 84%;
}

... (CSS code snippet continues) 

Answer №1

To achieve the desired positioning, simply use the following CSS:

#main {
    position: fixed;
    right: 0;
    bottom: 0;
}

(Feel free to adjust the values of "right" as needed.)

It is recommended to avoid using properties like:

#main {
    left: 600px;
    margin-top: 132px;
    margin-left: 399px;
    margin-right: 399px;
}

as these are considered as "magic" numbers. By setting the height of your form holder correctly, the issue will be resolved.

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

Logging DOM elements with Electron's webview preload feature

Within my Electron program, I am utilizing a webview in my index.html file. The webview is equipped with a preloader, and my goal is to manipulate the DOM of the webview specifically, not just the index.html file. In my preloader code snippet below, the c ...

Discover the nearest class and smoothly expand it with the slideDown function in jQuery

Hey there, I'm working on implementing a "View More" button on my page. The button will reveal another unordered list that currently has the class of "hidden-list". When the user clicks on "View More", I want it to slideToggle the hidden-list element ...

Using jQuery to add or remove multiple classes at once

My navigation tabs use jQuery to add and remove classes for the active tab. However, I'm facing an issue where the active class is not removed when a new tab is clicked or when the user scrolls to a new section. Please refer to the following gist for ...

Responsive design with Semantic UI

Can you please provide an example of how to design for different screen sizes using Semantic UI instead of Bootstrap? I'm looking for something similar to Bootstrap's sm and lg classes. For instance, would it look like this: <div class="col s ...

I am encountering an issue where the function send_mail is receiving multiple values for the argument fail_silently

https://i.sstatic.net/QUt2A.png My small program encountered an error when attempting to email information from a form. Here's the type of error I got: I'm writing a simple little program ... when I'm trying to email this info. from that fo ...

Utilizing Knockout to Render JSON List Items

Utilizing Knockout.js to dynamically update a view from JSON response has been my current focus. The structure of the JSON is as follows: var data = { "Properties": { "Engine Capacity": "1499cc", "Doors": 3, "Extras": [ "LED lights", ...

CSS code completion in PhpStorm is not functioning properly for Twig extended templates

Currently, I am working with PhpStorm 2016.1 and facing an issue with file autocomplete. The scenario is as follows: @mycss .style {color : red} @base.html.twig [...] <link rel="stylesheet" href="/vendor/mycss.css" /> <!--HERE AUTOCOMPLETE OF s ...

Incorporating Material-UI themes within styled components

Trying to incorporate theme spacing value in a styled component but facing issues. Initially, the style was applied to the button, but now it is not working as expected. You can view the problem here: sandbox. import React from "react"; import ...

Leveraging Bootstrap column classes with diverse div heights

Currently, I am working on a layout design using Bootstrap 3 that involves eight text divs. These divs have almost the same height, but some are slightly taller depending on the screen width. My goal is to arrange them into three columns on desktop and th ...

Show various Bootstrap Alert Messages based on the type of error detected?

Trying to figure out how best to explain this, here it goes! I am working on a website and I want to incorporate alert messages. Check out some examples here. Depending on the form inputs, I need different alerts to be displayed. PHP will validate the in ...

The positioning of a div element is not functioning as expected

I am currently updating my portfolio project. The page I am working on includes an image with a specific date displayed on it. I want to add text below the image, but I am encountering some issues: The text I want to include is meant to be a link, like th ...

Storing data in a text or HTML file using server-side JavaScript

Currently, I am working on a JavaScript form that involves saving user-entered variables to either a .txt file or a new webpage with the variables pre-filled in the inputs. I know that JavaScript cannot directly manipulate the user's machine, but I am ...

Utilize jQuery, Flash, or HTML5 to upload an image

Does anyone know of an upload tool or plugin that has a similar look and functionality to the one used on Codecanyon's website? I tried Uploadify, but it doesn't work on all browsers. I need something that is compatible with all browsers, whether ...

Submit the form using the GET method and update the URL

<form method=\"GET\" action=\"http://www.$domain/search/\"> <input type=\"search\" id=\"search\" name=\"search\" value=\"terms\"> </form> This form will be directed to the follo ...

Calculate the total number of blank input boxes within a specific row of the table

What is the method to count the number of input boxes without a value in a table row using jquery? For instance: <table id="table1"> <tr class="data" id="row5"> <td><input type="text" value="20%" /></td> <td><input ...

"Enhance User Experience with Multilevel Dropdowns in Bootstrap 4 - Submenus Aligned to the Top

I recently embarked on a project that involved using Bootstrap 4.4, The project is an eCommerce grocery store with departments comprising categories and subcategories. The main menu became very lengthy when using the default code, so I encountered some al ...

Tips for inverting the z-index order of stacked divs

On my webpage, I have set up multiple columns enclosed in divs like this: <div class="first column" style="width:33%; float: left;"></div> <div class="column" style="width:33%; float: left;"></div> <div class="last column" style ...

What is a PHP self-generating variable?

Is it possible to use a form variable as its own URL? It may be difficult to explain, but here's an example: matchmaking.php: $search_summoner = $_POST['search_summoner']; echo '<form method="post" action="matchmaking.php?searc ...

Impact of designs on the elements within components

Here's a CSS query I have: If I have the code below, does the styling apply to the contents of v-container but not v-container itself? <v-app id="inspire"> <v-container justify-center style="max-width: 1200px"> <v-layout row ...

Adjust grid percentages using jQuery Mobile

Struggling with creating a grid that includes form drop-downs and text boxes. Desiring the grid to be divided into sections of 25%, 50%, 25%, but having trouble understanding the grid system syntax. <fieldset class="ui-grid-b"> <div clas ...