Struggling with creating an html file that is responsive on mobile devices

I am currently utilizing bootstrap 4 for the construction of a website. I have encountered an issue where my homepage does not display properly on handheld devices when using Google Chrome's device toggle toolbar. The homepage requires scrolling to view all three posters, but if I click on movie1, the content displays perfectly without any scrolling necessary. It is worth noting that both pages utilize the same CSS file.

To address this issue, I have ensured that the following code is included in both HTML files:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

Additionally, the following media queries have been integrated into the CSS file:

@media (min-width: 768px) and (max-width: 992px){
}
@media (min-width: 480px) and (max-width: 767px) {
     
}

The head code snippet for the homepage is as follows:

<!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, maximum-scale=1.0, shrink-to-fit=no, user-scalable=0">

        <link rel="icon" href="movie-symbol-of-video-camera_icon-icons.com_72981.png">
        <link rel="stylesheet" href="style.css">
        <title>indextest</title>
        <style>
            
        </style>
    </head>

And for the movie1 page:

<!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="icon" href="../static/images/movie-symbol-of-video-camera_icon-icons.com_72981.png">-->
    <link rel="icon" href="movie-symbol-of-video-camera_icon-icons.com_72981.png">
    <link rel="stylesheet" href="style.css">
    <title>Document</title>
</head>

If you have insights or suggestions on why one page is functioning correctly while the other is not, please do share your thoughts. Thank you!

Below are images illustrating the problem: https://i.sstatic.net/FS9No.png

Situation where content fits perfectly with no need for scrolling below: https://i.sstatic.net/0RWu3.png

Answer №1

If you're working with bootstrap 4, it's best to utilize bootstrap 4 classes for responsive design and CSS media queries for alternative views. You can also create custom classes to tailor the display based on your preferences.

Here are some examples that demonstrate responsiveness across all screens using bootstrap 4 grid classes and other relevant classes.

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container-fluid">
  <h1>Home Page</h1>
  <div class="row">
    <div class="col-1">
        <img src="www.google.com">
    </div>
    <div class="col-11">
        <p>A movie poster for movie 1</p>
    </div>
  </div>
  <div class="row">
    <div class="col badge badge-success my-2 mx-2">Netflix</div>
    <div class="col badge badge-success my-2 mx-2">Amazon Prime</div>
    <div class="col badge badge-success my-2 mx-2">Hulu</div>
    <div class="col badge badge-success my-2 mx-2">Disney+</div>
  </div>
</div>

</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>

<div class="container-fluid">
  <h1>Home Page</h1>
  <div class="row">
    <div class="col-1">
        <img src="www.google.com">
    </div>
    <div class="col-11">
        <p>A movie poster for movie 1</p>
    </div>
  </div>
  <div class="row">
    <div class="col badge badge-success my-2 mx-2">Netflix</div>
    <div class="col badge badge-success my-2 mx-2">Amazon Prime</div>
    <div class="col badge badge-success my-2 mx-2">Hulu</div>
    <div class="col badge badge-success my-2 mx-2">Disney+</div>
  </div>
</div>

</body>
</html>

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

Is it possible to deselect a checkbox if a radio button is selected, and vice versa?

I'm presenting these two options: <div class="pricing-details pricing-details-downloads"> <h4>Single purchase (60 lessons)</h4> <h4>Bulk Purchase: Lesson</h4> <div class="pricing-details-separator">&l ...

JQuery Anchor Link Scrolling Problem on Specific Devices

I'm having an issue where my webpage does not scroll correctly to an anchor when a link is clicked. The problem arises from the header size changing based on the viewport width. While it works fine in desktop Chrome, in the mobile version the header h ...

Why is it not possible for me to place my image and text side by side?

I've been working on my personal portfolio website and ran into an issue when trying to position the image with text that says Ib student. I attempted using the bootstrap box model which didn't work, followed by using float, but that also didn&ap ...

Tips for specifying headings for a particular div ID

I'm attempting to customize the font-family of the headings within my header section differently from the headings located elsewhere on the webpage. Unfortunately, I am encountering difficulties in ensuring that this style change only affects the spec ...

Here's a unique rewritten version: "Achieving a looping carousel with autoplay in Angular 2+ using with

https://i.sstatic.net/MmmOg.jpg Could someone provide recommendations for an image carousel that is compatible with angular 8? I would also like to know how to customize the images inside the carousel specifically for small devices. Thank you in advance! ...

Pressing a shortcut key will direct the focus to the select tag with the help of Angular

I was trying to set up a key shortcut (shift + c) that would focus on the select tag in my form when pressed, similar to how tab works. Here is the HTML code for my form's select tag: <select id="myOptions"> <option selected> Opti ...

The feature to swap out the thumb of a range slider with an image is currently not

I'm attempting to design a unique range slider using CSS. <style> .slide-container { width: 300px; } .slider { -webkit-appearance: none; width: 100%; height: 5px; border-radius: 5px; background: #FFFFFF; outline: none; opacity: ...

Need help creating perfect round buttons with bootstrap 4?

After incorporating this fiddle into my code, the goal was to design a circular button. View Fiddle Here The code provided is for bootstrap 3. However, when using it with bootstrap 4, the button ends up being square instead of circular. See example here: ...

Determine the presence of a value within a specific column of an HTML table using jquery

When I input an ID number into a textbox, it shows me the corresponding location on a scale in another textbox. You can see an example of this functionality in action on this jsFiddle: http://jsfiddle.net/JoaoFelipePego/SdBBy/310/ If I enter a User ID num ...

Styling Process Steps in CSS

Just starting out with CSS! I'm looking to replicate the Process Step design shown in the image. https://i.stack.imgur.com/Cq0jY.png Here's the code I've experimented with so far: .inline-div{ padding: 1rem; border: 0.04rem gray ...

Ways to exhibit API information leveraging the prowess of Ajax

I am looking for a way to utilize the API in order to present data in an organized manner, similar to the following example: Job Title: Agricultural and Related Trades Percentage of Occupancies in Area: 15.41% Unfortunately, my attempt to showcase the d ...

Javascript code experiences a shift in two different styles within a single conditional statement

I'm new to web design and I'm having trouble getting this code to work properly. Can anyone help me fix it so that both styles are applied correctly? // Access the sign_up modal window var modal = document.getElementById('id01'); // A ...

Using Jquery and CSS to add a class with a 1-second delay when the mouse enters

I have successfully implemented the addClass function in my code, but I'm encountering issues when attempting to use delay or setTimeout functions. It's important to note that I'm avoiding the use of webkit attributes in CSS. If anyone has ...

Guide on defining keyframes in a CSS animation based on a specific property value

In CSS animations, keyframes are defined using percentages to determine their position: @keyframes foo { 0% { ... } 50% { ... } 100% { ... } } I'm working on a basic animation where an object smoothly moves across the screen. However, I ...

HTML dynamic voting system

I'm new to coding in HTML and I have a specific challenge that I need help with. I want to display a value on my webpage that increases every time a user clicks a button. Below is the code I have written so far: <script type="text/javascript& ...

Utilize page variables to activate audio clips upon clicking

Can someone assist me with a script that activates an audio clip when five icons on a page are clicked? The image of the icons can be found below: https://i.stack.imgur.com/mBC6o.png Here is the HTML code: <div class="slide overlay-container" id="int ...

Creating a simulated textarea with a scrollbar and dynamically refreshing the content

Due to limitations on markup content inside <p> tags, I have decided to create my own custom textbox. This textbox will function as a console where the battle progress is logged. Initially, I attempted using nested divs for each log, but encountered ...

Tips for adjusting the icon size within the <IconContext.Provider> dynamically

Currently, I am using the 'IconContext.Provider' tag to style my icons from the 'react-icons' library. Are there any solutions available to dynamically change the size of the icon based on the size of my media? Is using the global styl ...

The issue of AngularJS failing to bind object properties to the template or HTML element

Just dipping my toes into angularJS, following Todd Motto's tutorials, and I'm having trouble displaying object properties on the page. function AddCurrentJobs($scope){ $scope.jobinfo = [{ title: 'Building Shed', description: ...

Issue with Sub-Menu closing unexpectedly upon hovering over Menu item

I created a webpage with navigation links that trigger separate menus to open upon hovering. Although I have successfully implemented this functionality, I encounter an issue when trying to click on a link within the sub-menu as it disappears. Below is a ...