What causes fluctuations in div position across various locations?

I've encountered an issue while working on a multi-locale project using the same CSS for all locales (48 in total). In some locales, the position of a div is automatically changing. How can I address this problem?

For example: en_gb and de_de are displaying correctly, but sv_se locale is causing the div's position to be different.

1. Screenshots for en_gb:
https://i.sstatic.net/JZh53.png

  1. Screenshot for sv_se:
    https://i.sstatic.net/uGVS8.png

@media only screen and (max-width: 920px)  {

    .blahyear,
    .termscondition,
    .privacy,
    .generaldata {
        padding:0% 5% 2% 7%;
    }
}

@media only screen and (max-width: 415px) {
    .blahyear{margin-top: 97px;;}
    .privacy{margin-top: -139px;}
    .generaldata{margin-top: -101px;}
    .termscondition{margin-top: 136px;
        margin-left: -162px;}
    .footerNav{ margin-top: 20px;}
}
<div class="footerText footerNav">
                <ul id="footer_ul">
                    <li class="blahyear"><a (click)="reloadIfSamePage($event);" id="blah" i18n="@@blahblah">blah-blah {{showYear}}</a></li>
                    <li class="termscondition"><a (click)="reloadIfSamePage($event);" id="footerTerms" i18n="@@terms_conditions">TERMS AND CONDITIONS</a></li>
                    <li class="privacy"><a (click)="reloadIfSamePage($event);" i18n="@@information_privacy">YOUR INFORMATION AND PRIVACY</a></li>
                    <li class="generaldata"><a (click)="reloadIfSamePage($event);" i18n="@@data_protection">GENERAL DATA PROTECTION REGULATION</a></li>
                </ul>
            </div>

Answer №1

When utilizing values in percentages (%), the measurements are relative to the width/height of the container (which can also be the body). This means that as the browser window is resized, the sizes change and the measurements also change accordingly.

In this case, the measurements adjust according to the body.

To avoid this issue, absolute values such as pixels (px), centimeters (cm), etc., can be used in the padding property.

@media only screen and (max-width: 920px) {
  .tomtomyear,
  .termscondition,
  .privacy,
  .generaldata {
    padding: 0 5px 2px 7px;
  }
}

@media only screen and (max-width: 415px) {
  .tomtomyear {
    margin-top: 97px;
    ;
  }
  .privacy {
    margin-top: -139px;
  }
  .generaldata {
    margin-top: -101px;
  }
  .termscondition {
    margin-top: 136px;
    margin-left: -162px;
  }
  .footerNav {
    margin-top: 20px;
  }
}
<div class="footerText footerNav">
  <ul id="footer_ul">
    <li class="tomtomyear"><a (click)="reloadIfSamePage($event);" id="tomtom" i18n="@@tomtom">&copy;TOMTOM {{showYear}}</a></li>
    <li class="termscondition"><a (click)="reloadIfSamePage($event);" id="footerTerms" i18n="@@terms_conditions">TERMS AND CONDITIONS</a></li>
    <li class="privacy"><a (click)="reloadIfSamePage($event);" i18n="@@information_privacy">YOUR INFORMATION AND PRIVACY</a></li>
    <li class="generaldata"><a (click)="reloadIfSamePage($event);" i18n="@@data_protection">GENERAL DATA PROTECTION REGULATION</a></li>
  </ul>
</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

Implementing an alert box upon redirect with PHP

This question is pretty straightforward. I have a form on my index.html page and PHP code to submit that form to an external URL, then redirect back to the index: <?php Echo "<style>body{background:#3e4744}</style>"; Echo "<style>h2{ ...

Using the $http Angular service does not alter the passed array

Currently diving into Angular and facing a roadblock with the $http service and a JSON array. Within my code, there's an array labeled names. While I'm able to display its content within the function, an error pops up when trying to do so outside ...

Adjust the dimensions of an element using Protractor

When using the getSize method, I am able to determine the size of an element but I am struggling to understand how to change its height. To provide some additional context, my goal is to verify if a user can resize a textarea element. Should I simply adju ...

Juggling PHP scripts within javascript

Can you help me with a question I have? I am working on multiple JS scripts, such as this one: <script> $('#mapveto1').click(function() { $('#mapveto1').addClass('banned'); $('#map1').text('cobble ...

Changing the Stacking Order of Full-Width Columns in Bootstrap v3

Is it feasible to rearrange the sequence of full width columns in Bootstrap v3? Take into account... -xs (A and B both assigned col-xs-12) [ A ] [ B ] -sm (A and B both designated col-sm-12) [ B ] [ A ] I am aware of the option to use hide/show meth ...

toggle the outer div along with its corresponding inner div simultaneously

On one of my pages (let's call it "page1"), I have multiple divs, some nested within others. These divs are initially hidden and toggle on when a specific link is clicked (and off when clicked again). To view a nested div, the outer div must be opened ...

An element that automatically adjusts to the height of the body

I have been struggling to make my div fit the body's height and always stay at the bottom when I scroll. Initially, I set it to 100% height but soon realized that this is not the correct solution. While scrolling, I noticed a gap between the bottom of ...

What is the technique behind Gmail Email's Hover effect implementation?

Behave Annual keeps sending me emails about upcoming events. Recently, I noticed something strange in their newsletter. All the buttons and some text sections had CSS hover effects applied to them. When you hovered over them with your mouse, the color woul ...

Challenges with integrating PHP and JavaScript technologies

I am currently facing a challenge with transferring data from a PHP file to Javascript. I have set up a PHP file to pull data from a database and display it in HTML. My goal is to load this data when the page loads, store it in JavaScript arrays, and acc ...

Using HTML5 and CSS for 3D transformations along with stacking divs to create a unique accordion

Is there a way to stack divs vertically above each other and use CSS3 3D transforms to create a folding effect between them? I've tried rotating the divs on their X axis, but it leaves gaps between each div because they don't collapse into each o ...

Exploring the Transition from React.js with Material UI to Next.js for Server-Side Rendering: A Comparison of Tailwind CSS, Material UI, and Chakra UI

Currently, I am in the process of moving my React.js application with Material UI components to Next.js for server-side rendering (SSR) while considering some UI changes. In my research, I have come across three UI frameworks: Material UI, Chakra UI, and T ...

The concept of transparency and the overlay effect: uncovering the formula

I am working on developing a unique system that involves utilizing various div elements and adjusting their opacity levels. Here are some specific examples I am dealing with: envision all the divs being black. - When two divs overlap, each with an opacity ...

Scroll effect for read-only text input with long content inside a div

Is there a way to replicate the scroll functionality of a text input with readonly="readonly"? When the text exceeds the box size, you can highlight and scroll to view it all without a visible scrollbar. I am interested in achieving this effect within a p ...

CSS - Inconsistencies in size rendering across Chrome and Safari

I'm a Computer Science freshman and I created a website a few weeks ago. Initially, I checked it only on Safari and everything looked fine. However, when I tried it on Google Chrome, the layout appeared completely different. How can I resolve this iss ...

The navigation bar expands in height as the media width changes

I have a rather straightforward navbar: <nav class="navbar navbar-default navbar-inverse navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header pull-left"> @Html.ActionLink("Contact ...

How To Access a View by Clicking in Ionic Framework

I have designed the main screen shown below. When each link is clicked, it should open the corresponding view. https://i.sstatic.net/H84jt.png Here is what I have created so far: Main Screen <body ng-app="starter"> <ion-pane> < ...

Guide on configuring href tags in single-page JavaScript/HTML5 apps

After developing a "small" single page web application using python/django/backbone, similar to a basic Todo List app, a challenge arose regarding maintaining SEO-friendly href attributes without forcing users' browsers to reload the entire app at a n ...

Scroll the table automatically when the currently selected row is the second-to-last row

Having trouble with a scrolling table issue. https://i.sstatic.net/PFyN3.png Upon page load, the first row (ROW 1) is automatically selected and highlighted. Clicking the next button selects and highlights the subsequent rows. However, once ROW >= 8 (e ...

Issue with Google Map Info Windows resizing automatically, no changes have been made to the code

Take a look at my map application. By clicking multiple times on a red marker, you will notice that the info window changes size until it becomes unusually large, affecting all other windows as well. Interestingly, previous versions of my code from 1 month ...

Triggering keydown event on an Angular directive using jQuery's .trigger() function

After developing an edit directive that wraps an HTML input in a stylish frame, I moved on to creating a unit test. The goal was to verify that when I type into the input field, the form controller's dirty state is properly set. To simulate this acti ...