Tips for optimizing your webpage for mobile responsiveness

Having an issue with my webpage responsiveness on a Moto G4 device. The web development text is aligned to the right, but I want it centered. How can I achieve this for Moto G4 view?

index.html

This is where my full code is located: index.html

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" type="text/css" href="css/style.css">
  <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css"
    integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous" />
...
...
...
</body>

</html>

Answer №1

One trick that worked for me was removing a typo in the code, replacing it with p-0 in the parent element of <h1>. It may seem like unnecessary padding doesn't make much difference on larger screens, but it can have an impact on smaller screens, so I decided to remove the padding entirely.

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" type="text/css" href="css/style.css">
  <link rel="stylesheet" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css"
    integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous" />
  <link rel="preconnect" href="https://fonts.gstatic.com">
  <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@600&display=swap" rel="stylesheet">

</head>

<body>

  <!-- Navbar Start -->
  <nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top shadow-sm p-3 mb-5"
    style="background-color: #cadefc !important; color:#798777;">
  ...

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav ml-auto">
          ... 
        </ul>
      </div>
    </div>
  </nav>

  <!-- banner start -->
  <section class="banner p-5" style="background-color:#f7f7f9">
  ...
  <script src="index.js"></script>
  <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSS...
  ...
  <script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfe...
  <script>
    AOS.init();
  </script>
</body>

</html>

Answer №2

The h1 element you mentioned contains a closing <span> tag but is missing the opening <span> tag.

<h1 class="text-center">Web Development</span></h1>

To correct it, use:

<h1 class="text-center">Web Development</h1>

Answer №3

In my usual practice, I tend to implement this functionality using JavaScript.

Here is the code snippet:

 var ismobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);

if(ismobile)
{
    //Code specific for mobile devices
}

The variable "ismobile" will determine whether the user is accessing the site via a mobile device or a PC. Any code written within the if statement will only execute on mobile devices.

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

Accessing each element of an array list individually from local storage

I'm currently working on a practice todo application, where I can add and remove tasks. However, I noticed that when I refresh the page, all the data is lost. To address this issue, I decided to utilize the localStorage feature to save the task lists ...

Ensure that the input button for uploading is only accessible when checked and is marked as

Most of my previous questions have been about input boxes and SQL, as I am still in the learning process. Any help is greatly appreciated. My current question revolves around displaying a button to upload an image using PHP (although for this example, I w ...

Leveraging the power of jQuery and vanilla JavaScript to create a pop-up print window for a Div element within a CMS platform that does not support media query stylesheets

I have been grappling with this particular issue for weeks now, seeking guidance from previous inquiries here. Yet, despite the helpful hints, I am still struggling to find a viable solution. My website features a scrolling sidebar measuring approximately ...

I am seeking guidance on retrieving the value of a text box that is activated by a radio button through jquery within the provided code

When conducting my test case, the user is presented with a choice between ielts and toefl. If the user chooses ielts, an input box appears where they can enter their ielts score. My goal is to extract and store the value entered in that input box. Check ou ...

Display logo when website has been scrolled

On my website, I want to display a logo in the header only when the site has been scrolled. I attempted to accomplish this with JavaScript: if(document.getElementById("div").scrollTop != 0){ document.write("<img src='logo.jpg'>"); } How ...

Loading all assets in advance

Is there a one-size-fits-all method to preload all assets before using them? I need to load various images, audio files, and some .swf files before my application launches. Right now, I load images by creating new <img> elements with the image path a ...

What causes the vertical width of the clickable area on a range input to be larger than anticipated?

The vertical width of the clickable area (track) on the range input appears larger than expected in my Chrome browser (version 102.0.5005.63). Interestingly, it displays correctly in the code snippet. Is this a bug specific to Chrome? <div id="di ...

Attempting to incorporate Google charts into a div using jQuery's load function

Trying to incorporate a basic Google chart using jQuery .load functionality to transfer the chart into another webpage with a specific containing DIV: <html> <head> <script type="text/javascript" src="https://www.google.com/jsapi">< ...

Tips for accessing CSS properties on the img tag

I could use some assistance with CSS. I am in the process of creating a tree structure using many <ul> and <li> tags. The issue arises when I have multiple <li> elements with a specific class, each containing an <img> tag. How can ...

Tips on introducing a random pattern into a Javascript gaming experience

To kick off the game, let's generate a pattern randomly. Follow these steps: -Include a function that generates the pattern. (Hint: JavaScript's Math.random function might come in handy) -Invoke your new function from the startGame function I&a ...

Difficulty aligning headings in HTML

I'm puzzled by a strange 1px gap on the left of my h2 heading, which sits atop an h3. The font sizes are set to 40px for h2 and 12px for h3. Can anyone help me solve this mystery? Any assistance would be greatly appreciated! Thank you body { pa ...

When the loop is malfunctioning due to a certain condition

what happens if the condition in the controller file is not executed during runtime... ...

The issue with displaying long text in HTML select options in Internet Explorer 9

Having trouble with an HTML select element in IE9 when in compatibility view with IE7 standards. <select ...> <option title="test1">test1</option> <option title="test2">test2</option> <option title="longer text.. ...

How can the printing of content be adjusted when the browser zoom function is activated?

Is there a way to prevent the content from zooming when printing while the browser is zoomed in? The goal is for the printing (using iframe) to remain unchanged even if the browser is zoomed. I attempted: document.body.style.transformOrigin = 'top le ...

What could be preventing the fill color of my SVG from changing when I hover over it?

I am currently utilizing VueJS to design an interactive map showcasing Japan. The SVG I am using is sourced from Wikipedia. My template structure is illustrated below (The crucial classes here are the prefecture and region classes): <div> <svg ...

What is the best way to incorporate rounded images into a Bootstrap carousel?

Struggling to display only the rounded images when using a bootstrap carousel. Even with overflow:hidden, it's not working as intended. Seeking assistance on how to achieve this! ...

Flawlessly Outputting PHP and HTML

When querying a result from a table, I face an issue where the text does not automatically wrap to a new line if it's too long. This results in the text being displayed on a single line and often extending off the page. How can I ensure that the text ...

Issues with Angular's http get functionality not functioning as expected

I'm experimenting with an API on apiary.io and attempting to retrieve data from it using Angular, but I'm encountering issues with the call. The setup seems straightforward, so I'm not quite sure what's causing the problem: HTML: < ...

Tips on incorporating a scrollbar into a table using PHP?

I need help figuring out how to add a scroll function to my table that is generated in a PHP file. I prefer not to implement the scroll feature in a separate style.css file, I want it to be directly embedded in the PHP file itself. Below is the code I ha ...

Creating a search field in Bootstrap 4 that emulates material design, facing challenges with transition animations

I tried to create a material design search field using Bootstrap form input. While I was able to make it work, I noticed a small issue with the focus state. When I click inside the field, the underline animation runs smoothly. However, when I click outside ...