The body and HTML elements are bloated with an excessive amount of

Before we dive in, check out this code pen.

CSS

<body>
  <div class="header">
    <img src="https://images.unsplash.com/photo-1586244439413-bc2288941dda?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1050&q=80" alt="" class="profile-image">
    <p class="name-text">
      Hello👋🏼 <span class="IGHandle">| @something</span>
    </p>
    <div class="description">
      <p>Nothing here... just some lorem ipsum text</p>
    </div>
  </div>
  <div id="other-links">
   
  </div>
  <div id="social--main">
    <script type="text/javascript" src="js/addSocialItem.js" charset="utf-8"></script>
  </div>
</body>

</html>

SCSS

body {
  overflow-x: hidden;
  height: 100vh;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: 'Raleway', sans-serif;
  margin: 0;
  padding: 0;
}

* {
  margin: 0;
  padding: 0;
}

a {
  text-decoration: none;

  &:active,
  &:hover,
  &:visited {
    text-decoration: none;
  }
}

.header {
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  height: auto;

  .profile-image {
    z-index: 10;
    height: 175px;
    width: 175px;
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: 5px 5px 20px rgba(#335d2d, 0.2);
  }

  .name-text {
    font-size: 20px;
    font-weight: 700;

    .IGHandle {
      font-weight: 500;
      color: rgba(black, 0.7);
    }
  }

  .description {
    max-width: 300px;
    padding: 10px;
    margin-bottom: 10px;

    p {
      font-size: 16px;
      color: rgba(black, 0.35);
      line-height: 1.4;
    }
  }
}

#social--main {
  display: grid;
  grid-template-columns: repeat(4, auto);
  grid-gap: 7px 7px;
  padding: 10px;
}

.social-item {
  margin: 7px;
  padding: 10px;
  display: inline-block;
  border-radius: 30%;

  .bx {
    align-self: center;
    font-size: 40px;
    padding: 0;
    margin: 0;
  }
}

#other-links {
  margin-bottom: 20px;
  margin-top: -15px;
  display: flex;
  flex-direction: column;
  align-items: center;

  .other-link {
    font-weight: 600;
    display: block;
    color: #2a3d66;
    position: relative;
    margin-top: 15px;
    width: 270px;
    height: auto;
    padding: 15px;
    font-size: 20px;
    background-color: rgba(#2a3d66, 0.2);
    border-radius: 20px;
  }
}

JS

/*jshint esversion: 6 */

var mainSocialtems = [{
  "name": "dribbble",
  "color": "234,76,137",
  "href": "",
  "classes": "bxl-dribbble",
}, {
  "name": "instagram",
  "color": "193,53,132",
  "href": "",
  "classes": "bxl-instagram",
}, {
  "name": "behance",
  "color": "23,105,255",
  "href": "",
  "classes": "bxl-behance",
}, {
  "name": "linkedin",
  "color": "0,119,181",
  "href": "",
  "classes": "bxl-linkedin",
},];

var socialMain = document.getElementById('social--main');

for (var i = 0; i < mainSocialtems.length; i++) {
  const linkContainer = document.createElement('a');
  linkContainer.setAttribute('class', 'social-item');
  linkContainer.setAttribute('href', mainSocialtems[i].href);
  linkContainer.setAttribute('style', "background-color: rgba(" + mainSocialtems[i].color + ", 0.08)");

  const link = document.createElement('i');
  link.setAttribute('class', 'bx ' + mainSocialtems[i].classes);
  link.style.color = `rgb(${mainSocialtems[i].color})`;
  linkContainer.appendChild(link);

  socialMain.appendChild(linkContainer);
}

var linkItems = [{
  "name": "2020 so far",
  "color": "207,117,0",
  "href": "",
}, {
  "name": "event update",
  "color": "106,25,125",
  "href": "",
},];

var linkBox = document.getElementById('other-links');

for (var i = 0; i < linkItems.length; i++) {
  const linkContainer = document.createElement('a');
  linkContainer.setAttribute('class', 'other-link');
  linkContainer.setAttribute('href', linkItems[i].href);
  linkContainer.setAttribute('style', "background-color: rgba(" + linkItems[i].color + ", 0.2); color: rgb(" + linkItems[i].color + ")");

  linkContainer.innerText = linkItems[i].name + " ";

  const linkIcon = document.createElement('i');
  linkIcon.setAttribute('class', 'bx bx-link-external');
  linkContainer.appendChild(linkIcon);

  linkBox.appendChild(linkContainer);
}

Everything looks good on desktop, but when viewed on mobile, the page seems to have excessive space and elements are shrinking despite being set in pixels.

Here's a visual reference

This issue is new to me and I'm struggling to identify the cause.

Any assistance would be greatly appreciated!

Thank you

Answer №1

Before we dive into anything else, let's double-check that you have the meta viewport properly set up.

<meta
  name="viewport"
  content="width=device-width,user-scalable=no,minimum-scale=1,maximum-scale=1"
/>

Next, make sure to update your body's height property to min-height.
This adjustment ensures that users can scroll through content that exceeds the available viewport space. 😊

body {
   overflow-x: hidden;
   min-height: 100vh;
   box-sizing: border-box;
   display: flex;
   flex-direction: column;
   align-items: center;
   justify-content: center;
   text-align: center;
   font-family: 'Raleway', sans-serif;
   margin: 0;
   padding: 0;
}
...

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

The parent element is not able to apply the CSS text-decoration in jQuery

Is there a way to retrieve a specific CSS property of an element, even if it is inherited from its parent? The standard jQuery method .css() can help with this. Consider the following HTML structure: <div id="container"> some text<br> ...

Looking to transform a PHP output value

I have a form with checkbox input, and a hidden 'sibling' input attached to it, in order to generate values of either '0' or '3' based on the checkbox status. When unchecked, the value is '0', and when checked, the ...

jQuery for Special Characters

I am currently facing an issue with the character &gt; in my jQuery datatable. Strangely, it displays '>' correctly but when I click on a row, the character &gt; appears and I am feeling frustrated. Is there any solution to this probl ...

Using clip-path in SVG works perfectly on images, but unfortunately it does not work on div

I came across an interesting example on MDN about using a clip-path SVG on an image. However, it seems that the same clip-path does not work properly when applied to a div. Can anyone shed some light on: The reason why this code is not achieving the inte ...

Sending Data to a PHP Script

I attempted to use the code below to send values to another PHP page but I am not receiving any output. File: Send.html <form id="form1" action="get.php" method="get"> <input name="search_name" type="text" id="search_name" size="20.5" height="45 ...

Binding textarea data in Angular is a powerful feature that allows

I am looking to display the content from a textarea on the page in real time, but I am struggling to get the line breaks to show up. Here is my current code snippet: app.component.html <div class="ui center aligned grid">{{Form.value.address}}< ...

Incorporate validation features within a jQuery method

I am struggling with some HTML and jQuery code that generates links based on user input. HTML <input type="text" id="text" placeholder="Enter text" autofocus /> <a id="link1" class="btn btn-info" href="#" target="_blank"> Search 1 </a> ...

Enhance your webpage's body by zooming in using jQuery on Mozilla Firefox

I have a webpage and I would like to zoom its body when it loads using jQuery. However, the CSS zoom feature is not working in Mozilla Firefox. This is what I currently am using: $("body").css("zoom", "1.05"); It worked in Chrome, Opera, and Edge, but un ...

Apply CSS styling (or class) to each element of a React array of objects within a Component

One issue I'm facing involves adding specific properties to every object in an array based on another value within that same object. One such property is the background color. To illustrate, consider an array of objects: let myObj = { name: "myO ...

There is zero gutter in Bootstrap

Is it possible to use the bootstrap grid system without any gutters? I want to have 3 columns in one row like this: http://prntscr.com/6gpmhm. I have shared the markup for the CSS I am using, which is the default CSS of the framework. <section class ...

Modify an HTML document using a PHP script

I am creating a website that automatically generates an HTML template with some customizable text through a form. However, I want the ability to retrieve that text in the form after pressing a button or taking some action, so it can be edited. I've ...

Font on the internet that does not have the specific Germanic di

Just recently I purchased a new font and was excited to use it on my website using web fonts. However, upon closer inspection, I noticed that the umlauts such as ä, ü, and ö were missing from the font, leaving empty spaces where those characters should ...

Customizing styles in ZK based on theme

I am currently working on a ZK application that has been styled using CSS, specifically the colors from the Sapphire theme. My goal is to have environment-dependent themes - Sapphire for production and Breeze for stage. While I have successfully implemente ...

Creating a fixed footer within a div that is absolutely positioned using CSS

I am looking to implement a sticky footer within an absolutely positioned div element. My initial approach was to position the footer div absolutely as well - within an additional relatively positioned "page" div (which would contain the main content of t ...

Text in gray overlaying image background

I am attempting to design a layout that resembles the following: Although I can create the letter "A" using svg or clip-path, my challenge lies in maintaining the background inside the "A" aligned with the body background. Essentially, I want the backgrou ...

javascript close the current browser tab

Can someone please help me with a JavaScript code to close the current window? I have tried the following code but it does not seem to work: <input type="button" class="btn btn-success" style="font-weight: b ...

Pressing the button will allow you to select and copy the text within the

I am looking to incorporate a mock-chat feature into my website. The concept is to type something on the website, then click a button next to it which will move the text to a frame above. I attempted this using a textarea and even found a code for selectin ...

SB Admin 2 menu with multiple levels does not collapse as expected

I'm in the process of integrating the menu from the sb admin 2 template into my Ruby on Rails application: As I gradually added components to test functionality, I successfully implemented the top and side nav bars. However, I encountered an issue wi ...

When attempting to update a database, the Jquery ajax response is not being reflected

Currently, I am utilizing a dialog box for updating my database and removing services. However, I have encountered an issue where it only functions properly on the initial "remove" click. When I open the dialog box, I am presented with a list of 5 servic ...

"Trouble with getting the Twitter Bootstrap dropdown menu to function properly

Currently, I am facing a challenge with my project as the dropdowns on the menu are not functioning properly. Despite having all the necessary files included, it seems like there might be an issue within my code. You can view the page here: (please try t ...