Is your HTML website undergoing strange optimization after being live?

After publishing my site earlier today, I noticed some discrepancies in how it appeared when live versus during coding. Here is the code as it was originally:

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

However, this is what it actually looked like on my phone:

https://i.sstatic.net/oG9L8.png

Even upon viewing it on a computer, there were issues that made me question if these were optimization problems.... Below is the code - can anyone assist in ensuring all aspects of my site remain consistent across different devices? Your help would be greatly appreciated!

@font-face {
  font-family: "My Custom Font";
  src: url(fonts/font.ttf) format("truetype");
}

body {
  background: url(img/bg.png) no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  o-background-size: cover;
  background-size: cover;
  font-family: "My Custom Font", Times, serif;
  max-width: 100%;
  overflow-x: hidden;
}

#headerbg {
  height: 450px;
  width: 710px;
  background-color: rgb(28, 28, 28);
  position: relative;
  top: 100px;
  border-radius: 15px;
  opacity: 0.6;
}

.header {
  position: relative;
  bottom: 345px;
  color: white;
  padding-right: 30px;
}

#logo {
  position: relative;
  bottom: 605px;
  right: 210px;
}

#inputbg {
  width: 375px;
  height: 550px;
  background-color: rgb(28, 28, 28);
  position: relative;
  left: 168px;
  bottom: 150px;
  border-radius: 15px;
  opacity: 0.6;
}

.input {
  color: white;
  text-align: center;
  position: relative;
  bottom: 320px;
  left: 170px;
}

#firsttxt {
  position: relative;
  bottom: 900px;
  left: 45px;
  color: white;
}

#lasttxt {
  position: relative;
  bottom: 938px;
  left: 187px;
  color: white;
}

#emailtxt {
  position: relative;
  bottom: 933px;
  left: 103px;
  color: white;
}

#downloadhere {
  position: relative;
  bottom: 1512px;
  left: 169px;
}

#enterbtn {
  width: 135px;
  height: 50px;
  color: rgb(186, 209, 225);
  background-color: rgb(203, 38, 38);
  border-color: rgb(203, 38, 38);
  font-size: 20px;
  position: relative;
  text-align: center;
}

#benefits {
  position: relative;
  bottom: 1900px;
  color: white;
  text-align: center;
}

.pdfdisplay {
  position: relative;
  bottom: 860px;
  left: 175px;
}
<!DOCTYPE html>

<html>

<head>

  <title>P2 Fitness Company</title>
  <link rel="stylesheet" type="text/css" href="style.css">

</head>

<body>
  <center>
    <div id="headerbg"></div>
    <div class="header">
      <h1>FREE PDF WITH 7 TIPS TO BOOST <br>YOUR PROGRESS IN THE GYM</h>
    </div>
    <div id="logo">
      <img src="img/p2fitnesstransparent.png" width="350px" height="150px">
    </div>
    <div id="inputbg"></div>

    <div class="input">
      <form method="get" action="files/7tips.pdf">
        <input type="text" name="first" size="15">
        <input type="text" name="last" size="15"> <br> <br>
        <input type="text" name="email" size="20"> <br> <br>
        <input id="enterbtn" type="submit" value="DOWNLOAD">
      </form>
    </div>

    <div class="pdfdisplay">
      <img src="img/pdfdisplay.png" height="400px" width="400px">
    </div>
    <h5 id="firsttxt">FIRST*</h5>
    <h5 id="lasttxt">LAST*</h5>
    <h5 id="emailtxt">EMAIL*</h5>

    <img src="img/downloadhere.png" id="downloadhere">

  </center>

  <div id="benefits">
    <h2>BENEFITS OF PDF</h2>

    <h3>-Utilize the time you are<br>already spending in the gym</br>
      -Learn new ways to gain muscle<br>
      -Learn to live a healthier lifestyle<br>
      -Reduce risk of injury</h3>
  </div>

</body>

</html>

Answer №1

The issue here lies in the fixed dimensions specified in pixels, which hinders responsiveness on different devices. To tackle this problem effectively, consider utilizing responsive design techniques that adapt to various viewports.
Bootstrap emerges as a favorable choice for achieving responsiveness, along with leveraging properties like vw, vh, and vmin.
Check out this informative resource from W3Schools for further guidance.

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

Updating the Background Color of a Selected Checkbox in HTML

I have a straightforward question that I've been struggling to find a simple answer for. Can anyone help me with this? Here's the checkbox code I'm working with: <input type="checkbox"> All I want to do is change the backgr ...

JavaScript styling can be unpredictable at times

It seems like there's a mysterious logic at play that I can't quite grasp, and I haven't been able to find a solution online. The application of styles is inconsistent - sometimes they work, sometimes they don't, even though no changes ...

CSS issue encountered: "Value of property is not valid"

When working with CSS, I encountered an error stating "Invalid Property Value" while inspecting the transform element of the Service section in the Wall Street theme. Could someone kindly assist me with the necessary steps to rectify this issue? https://i ...

Height CSS does not conceal side bar hyperlinks

CSS .nested-menu { .list-group-item { cursor: pointer; } .nested { list-style-type: none; } ul.submenu { height: 0; } & .expand { ul.submenu { ...

How can we assign identical names to multiple textboxes generated by a loop?

I have a dynamic creation of multiple textboxes or textfields in JSP using a for loop. The quantity is determined at runtime based on a condition, so I can't specify the exact number. Each textbox has an onFocus event that triggers a function such as ...

Changing the main domain of links with a specific class attribute during an onmousedown event - is it possible?

We are facing a situation where we have numerous webpages on our blog that contain links from one domain (domain1.com) to another domain (domain2.com). In order to avoid manual changes, we are attempting to achieve this without altering the link (href). Th ...

Tips for boosting the performance of the float lerp function

I have been working on a soft raster renderer recently, but I am facing speed issues. Upon performance testing, it appears that the float lerp function is causing a bottleneck. Does anyone have any suggestions on how to improve the speed of this function? ...

Two Mistakes Found in the Dropdown Menu

Can anyone assist me with two errors I am encountering in my "Drop Down Menu"? Error 1: Whenever I hover towards the right direction in the sub-menu (e.g., Portfolio 2), a black box appears. This issue does not occur when hovering above the text (e.g., P ...

Is it possible to conduct a feature test to verify the limitations of HTML5 audio on

Is there a way to detect if volume control of HTML5 audio elements is possible on iOS devices? I want to remove UI elements related to the volume if it's not alterable. After referring to: http://developer.apple.com/library/safari/#documentation/Aud ...

Tips for arranging the items within the slider according to the specified direction (rtl, ltr) in the Owl Carousel slider for Angular

Is there a way to dynamically change the direction of the owl-carousel-o angular slider based on the selected language? Currently, I have set rtl: true in the owl-carousel configuration during initialization. However, when the user switches to a different ...

JQuery ID Media Queries: Enhancing responsive design with targeted

Is it possible to integrate a media query into the selection of an ID using JQuery? For example: $('#idname') $('@media (max-width: 767px) { #idname }') In essence, can you target the #idname with that specified media query in JQuery ...

Crafting a radiant sun with ThreeJS

I am working on designing a solar system in WebGL but I am facing challenges with setting up the lighting. My main goal is to incorporate a light source within the sun that casts light in all directions, while ensuring that my planets can both cast and rec ...

What is the best way to hide the jQuery modal I created?

Hello everyone! Currently, I am working on coding a simple JS modal that can be opened and closed smoothly. The issue I am facing is related to adding a click function to (.black-overlay) in order to fade out everything and close the modal. <div class ...

Issue with React Bootstrap Scrollspy not functioning correctly on Android mobile browsers

I am currently using bootstrap 5.2.2 within React to add Scrollspy functionality to my menu. The Scrollspy feature functions correctly in web browsers on laptops and iPhones. However, on Android mobile devices, the Scrollspy fails to update the active lin ...

How to arrange table data in Angular based on th values?

I need to organize data in a table using <th> tags for alignment purposes. Currently, I am utilizing the ng-zorro table, but standard HTML tags can also be used. The data obtained from the server (via C# web API) is structured like this: [ { ...

Is there a way to sequentially load two iframes, with the second one loading only after the first one is fully loaded

Having two different links that trigger ajax calls can be tricky if only one request is allowed per load. This may result in both iframes displaying the same data. Is there a way to work around this issue? Perhaps loading one iframe first and then triggeri ...

Different strategies for displaying a singular pie chart on multiple pages

I have implemented a pie chart on an HTML page and now I want to display this chart on multiple other HTML pages. Below is the JavaScript code for creating the pie chart: function piechart() { var chart; var legend; ...

The loading of the Bootstrap tagsinput has encountered an error

I am facing an issue with my Django application where tags are not loading properly in an input field using jquery. It seems like the application is unable to locate the bootstrap-tagsinput.css and bootstrap-tagsinput.js files. Can anyone provide guidance ...

When the loop is malfunctioning due to a certain condition

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

Is there a way to transfer JavaScript data to PHP?

<div> <p>This is a sample HTML code with JavaScript for tallying radio button values and passing them to PHP via email.</p> </div> If you need help converting JavaScript data to PHP and sending it via email, there are v ...