Bootstrap is an outdated page template that lacks responsiveness

My code below features a page designed using Bootstrap HTML and CSS, but it doesn't look right on all devices. For example, on mobile devices, the grid appears zoomed in and unresponsive. I tried removing

grid-template-columns: auto auto;
, which fixed the issue, but I still need to display 2 columns in each row. Is this a problem with Bootstrap or could it be that my responsiveness strategy is incorrect? Any assistance would be greatly appreciated. View image description here

<!DOCTYPE html>
<html>

<head>
   
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
  <link href="assets/js/scripts.js" rel="stylesheet" />
  <link href="assets/css/style.css" rel="stylesheet" />
  <link rel="stylesheet" type="text/css"
  <link href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a1b15093a485449544b">[email protected]</a>/dist/aos.css" rel="stylesheet">
  <script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9cfdf3efdcaeb2afb2ad">[email protected]</a>/dist/aos.js"> </script>
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="492b26263d3a3d3b2839097c6779677b">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3b5954544f484f495a4b7b0e150b1509">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="bootstrap.bundle.min.js"></script>
</head>

<style>
  .navbar {
    background-color: rgb(43, 59, 43) !important;
  }

  .h2,
  h2 {
    font-size: 21px;
  }

  img {
    vertical-align: middle;
    width: 250px;
  }
  .grid-container {
    display: grid;
    grid-template-columns: auto auto;
    grid-gap: 10px;
    padding: 10px;
  }

  .grid-container>div {
    /*background-color: rgba(255, 255, 255, 0.8);*/
    background-color: rgb(235, 235, 235);
    text-align: center;
    padding: 20px 0;
    font-size: 30px;
    height: auto;
  }
</style>

<body>
  <nav class="navbar navbar-expand-lg navbar-light bg-light">
    <div class="container">
      <img src="assets/images/logo.png" alt="" style="width: 59%;">
      <button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navbarCollapse">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarCollapse">
        <div class="navbar-nav">
          <a href="menu.html" class="nav-item nav-link active">menu</a>
          <a href="#" class="nav-item nav-link">home</a>
          <a href="#" class="nav-item nav-link">about </a>


        </div>

      </div>
    </div>
  </nav>
  <div class="container" ng-controller="CardController">
    <div class="grid-container" id="menu-items-container">
    </div>
  </div>
</body>


</body>

</html>
<script>


  products = [
    {
      "placeImage": "assets/images/item.png",
      "placeName": " salad  ",
      "price": 80
    },
    {
      "placeImage": "assets/images/item.png",
      "placeName": " salad ",
      "price": 65
    },
    {
      "placeImage": "assets/images/item.png",
      "placeName": "   salad ",
      "price": 30
    }

  ];
  console.log(products);
  const data = JSON.parse(JSON.stringify(products));

  function renderItem(item) {
    const base = document.createElement("div");
    const img = document.createElement("img");
    const title = document.createElement("h1");
    const price = document.createElement("h2");

    img.src = item.placeImage;
    title.textContent = item.placeName;
    price.textContent = item.price;

    base.appendChild(img);
    base.appendChild(title);
    base.appendChild(price);

    return base;
  }

  const container = document.querySelector("#menu-items-container");
  for (let item of data) {
    container.appendChild(renderItem(item));
  }
</script>

Answer №1

Seems like all you had to do was include .ms-auto in .navbar-nav and now the navbar is positioned correctly, right?

<!DOCTYPE html>
<html>

<head>
   
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
  <link href="assets/js/scripts.js" rel="stylesheet" />
  <link href="assets/css/style.css" rel="stylesheet" />
  <link rel="stylesheet" type="text/css"
  <link href="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6a0b05192a584459445b">[email protected]</a>/dist/aos.css" rel="stylesheet">
  <script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f4959b87b4c6dac7dac5">[email protected]</a>/dist/aos.js"> </script>
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1c7e7373686f686e7d6c5c29322c322e">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a6c4c9c9d2d5d2d4c7d6e69388968894">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="bootstrap.bundle.min.js"></script>
</head>

<style>
  .navbar {
    background-color: rgb(43, 59, 43) !important;
  }

  .h2,
  h2 {
    font-size: 21px;
  }

  img {
    vertical-align: middle;
    width: 250px;
  }
  .grid-container {
    display: grid;
    grid-template-columns: auto auto;
    grid-gap: 10px;
    padding: 10px;
  }

  .grid-container>div {
    /*background-color: rgba(255, 255, 255, 0.8);*/
    background-color: rgb(235, 235, 235);
    text-align: center;
    padding: 20px 0;
    font-size: 30px;
    height: auto;
  }
</style>

<body>
  <nav class="navbar navbar-expand-lg navbar-dark bg-light">
    <div class="container">
      <img src="assets/images/logo.png" alt="Logo Here" style="width: 59%;">
      <button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navbarCollapse">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarCollapse">
        <div class="navbar-nav ms-auto">
          <a href="menu.html" class="nav-item nav-link active">menu</a>
          <a href="#" class="nav-item nav-link">home</a>
          <a href="#" class="nav-item nav-link">about </a>
        </div>
      </div>
    </div>
  </nav>
  <div class="container" ng-controller="CardController">
    <div class="grid-container" id="menu-items-container">
    </div>
  </div>
</body>


</body>

</html>
<script>
  products = [
    {
      "placeImage": "assets/images/item.png",
      "placeName": " salad  ",
      "price": 80
    },
    {
      "placeImage": "assets/images/item.png",
      "placeName": " salad ",
      "price": 65
    },
    {
      "placeImage": "assets/images/item.png",
      "placeName": "   salad ",
      "price": 30
    }

  ];
  console.log(products);
  const data = JSON.parse(JSON.stringify(products));

  function renderItem(item) {
    const base = document.createElement("div");
    const img = document.createElement("img");
    const title = document.createElement("h1");
    const price = document.createElement("h2");

    img.src = item.placeImage;
    title.textContent = item.placeName;
    price.textContent = item.price;

    base.appendChild(img);
    base.appendChild(title);
    base.appendChild(price);

    return base;
  }

  const container = document.querySelector("#menu-items-container");
  for (let item of data) {
    container.appendChild(renderItem(item));
  }
</script>

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

"Remaining Elements" within a CSS Design

I am faced with a challenge where I have 4 elements nested inside a container element. The height of the container should be set to 100% of the browser window. The inner elements need to stack vertically, with the first two and last elements having a natur ...

The button's background color will vanish if you click anywhere outside the button or on the body of

Struggling with a tabpane created using HTML, CSS, and JavaScript. The problem arises when the background color of the active tab's button disappears upon clicking outside the button or on the body. While switching between tabs, I can change the color ...

Calculate the total with the applied filters

My goal is to sum the data from the Number table after applying lookup filters. The current issue is that the sum remains fixed for all values and doesn't take into account the filter. Here's the JavaScript function I'm using to search and ...

Concealing a Class on the Homepage in Joomla 3

Is there a way to only hide a certain class on the home page? <div class="search-wrapper"> .search-wrapper { background: none repeat scroll 0 0 #3d4895; height: 50px; margin-top: 10px; width: 100%; } I want this class to be visible ...

Having trouble converting response.data to a string in ReactJS

import React, { Component } from 'react' import TaskOneServices from '../services/TaskOneServices' import circle from '../assets/icons/dry-clean.png' import tick from '../assets/icons/check-mark.png' async function ...

What is the best way to add the current date to a database?

code: <?php session_start(); if(isset($_POST['enq'])) { extract($_POST); $query = mysqli_query($link, "SELECT * FROM enquires2 WHERE email = '".$email. "'"); if(mysqli_num_rows($query) > 0) { echo '<script&g ...

Having four videos displayed on one webpage can cause the browser to function at a slower

I have videos that are around 30 seconds long and 15mbs. I'm wondering if it's feasible to include them on a page or if I should opt for cover images instead. I would like to use the video as a separator similar to the design showcased at Does a ...

Trouble persisting in loading PopperJS and Bootstrap through RequireJS, despite following the suggested PopperJS version

Struggling to load jquery, popperjs, and bootstrap (v4-beta) using requirejs, I'm consistently encountering this error in the console: Uncaught Error: Bootstrap dropdown require Popper.js (https://popper.js.org) at bootstrap.js:6 at bootstrap ...

Styling for the bootstrap dropdown menu is missing

While attempting to incorporate a bootstrap dropdown menu, I noticed that despite applying the appropriate class to the sublist, the formatting and padding that is typically associated with bootstrap are not being retained. My current setup involves using ...

The MUI makeStyles() class has been implemented, yet the styles are not being displayed when using classList.add('class-name')

Currently, I am utilizing MUI makeStyles() to create a series of CSS classes. Within these classes, I am dynamically including and excluding one specific class to my Box element during file drag-and-drop events. The class is successfully added, as I can o ...

Is there a way to trigger a fabric.js event externally?

Is there a way to trigger a fabric.js event externally? For example, if I have a 3D model that tracks the mouse's position and provides the UV coordinates on the canvas, I want to be able to emit click, mousemove, and mouseup events. Currently, everyt ...

Is it deemed as an anti-pattern to establish directives for styling?

Currently, I am in the midst of developing a specialized component UI library for a specific project I'm involved in. This library will consist of unique stylized components with elements that are reused throughout. As I work on this project, I find ...

Implementing CSS counter-increment with jQuery

Is there a way to use jQuery to set the CSS counter-increment attribute on ".demo:before" even though jQuery cannot access pseudo elements directly? I recall seeing a suggestion on Stack Overflow about using a data attribute and then referencing that value ...

Error encountered in ASP.NET Core MVC due to dependency inversion with CRUD operations

Today I delved into dependency inversion. Prior to implementing this concept, my CRUD system was functioning well, but now I am encountering some errors. The error message says "Cannot implicitly convert type int to ContractLayer.UsersDto." In the image pr ...

Using Express.js to render an HTML table in a web page

Is there a way to display a full table using the res.render method? This is what I'm attempting to do: I need to define where to send one of my tables. main.hbs <html> ... <div id="main_frame" class="col s12">{{{bod ...

Tips for creating an input field that automatically expands and has a specific width

I am facing an issue with the alignment of my search field. Here is the code snippet: #menu_search{ position: absolute; width: 100%; max-width: 1280px; display: inline; float: right; right: 0px; z-index: 99; } I would like th ...

Tips for rotating a responsive table on a mobile device's screen

I am currently managing a blogger website that features an HTML table on the homepage. I am struggling with making this table responsive for mobile devices, and I would like it to look similar to the image provided below. Can someone guide me on how to ach ...

Like the Word outline view, the list view can be easily collapsed and expanded with a simple click

I've seen a few examples, but I haven't been able to achieve what I'm looking for. I need to extract text from a field and convert it into an outline view similar to the one in Word. Is this possible? Any help would be greatly appreciated. I ...

Pressing the reset button will initiate once the loader has finished

Hello everyone, I'm currently working on creating a button that transforms into a loader when submitted and then reverts back to a button after the form is successfully submitted. I suspect the issue lies within my JavaScript. I'm not sure how ...

One login for accessing multiple forms

I am trying to figure out a way to use one login for two different forms that serve different functions. How can I pass the login details between these two functions? Just to clarify, I only have knowledge of JavaScript and VBScript, not jQuery. For inst ...