Having trouble positioning the right side image on the Bootstrap 4 Landing page

Struggling to incorporate bootstrap 4 into my sample project for the right side background. I'm facing some conflicts and attempts to align it on the right side are not successful. Does anyone know how to do this correctly?

Thank you

// Navbar scroll js //

jQuery(function($) {
    "use strict";

        // Determining the position of the #main element and adding necessary offsets
        var mainbottom = $('#main').offset().top;

        // On scroll
        $(window).on('scroll',function(){

        // Rounding the scroll position for efficiency
        stop = Math.round($(window).scrollTop());
        if (stop > mainbottom) {
            $('.navbar').addClass('past-main');
            $('.navbar').addClass('effect-main')
        } else {
            $('.navbar').removeClass('past-main');
       }

      });
    
      /* Various navbar and scroll functionalities */
      
});
/*----- Main Classes -----*/

html * {
    text-rendering: optimizeLegibility !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

*, *:after, *:before {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

/* Rest of the CSS rules and media queries */
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Meta tags, Bootstrap CSS, fontawesome kit and other scripts -->
</head>
<body>
<!—Navigation bar section—>

<!—End of Navigation bar section—>

<!—Home section—>

<!—End of Home section—>

<!-- Optional JavaScript -->
<!-- jQuery, Popper.js, Bootstrap JS -->
</body>
</html>

Answer №1

I have made some modifications to the code. I removed the image and added the banner class to the root div. The banner class now looks like this:

.banner-one {
background-image: url(http://brotherslab.thesoftking.com/html/lotten/demo/assets/images/shape/banner-one.png);
    background-repeat: no-repeat;
    background-size: 100% 100%;
}

// Navbar scroll js //

JavaScript code for navbar scroll functionality goes here.
/* Main Classes CSS */

CSS code for main classes styling goes here.
<!DOCTYPE html>
<html lang="en">

HTML code for the landing page structure goes here. Including nav bar and home section elements.

Answer №2

I added the banner-one class to the 'home-land home-section' div, and now it's functioning properly.

// Navbar scrolling javascript //

jQuery(function($) {
    "use strict";

        // Calculate the bottom position of the #main element by adding its offset and height
        var mainbottom = $('#main').offset().top;

        // On scroll,
        $(window).on('scroll',function(){

        // Round the scroll position
        stop = Math.round($(window).scrollTop());
        if (stop > mainbottom) {
            $('.navbar').addClass('past-main');
            $('.navbar').addClass('effect-main')
        } else {
            $('.navbar').removeClass('past-main');
       }

      });
      // Collapse navbar on click
       $(document).on('click.nav','.navbar-collapse.in',function(e) {
        if( $(e.target).is('a') ) {
        $(this).removeClass('in').addClass('collapse');
       }
      });
    // Scroll to Top function
    $(window).on('scroll', function () {
      if ($(this).scrollTop() > 1000) {
          $('#back-top').fadeIn();
      } else {
          $('#back-top').fadeOut();
      }
    });
    // Scroll to top on click
    $('#back-top').on('click', function () {
      $('#back-top').tooltip('hide');
      $('body,html').animate({
          scrollTop: 0
      }, 1500);
      return false;
    });
    // Smooth scrolling using jQuery easing
    $('a.js-scroll-trigger[href*="#"]:not([href="#"])').on('click', function () {
      if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
        var target = $(this.hash);
        target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
        if (target.length) {
          $('html, body').animate({
            scrollTop: (target.offset().top - 54)
          }, 1000, "easeInOutExpo");
          return false;
        }
      }
    });
    // Close responsive menu on scroll trigger
    $('.js-scroll-trigger').on('click', function () {
      $('.navbar-collapse').collapse('hide');
    });
    // Activate scrollspy to add active class to navbar items on scroll
    $('body').scrollspy({
      target: '#mainNav',
      offset: 54
    });
});
/* Main Classes */
html * {
    text-rendering: optimizeLegibility !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
*, *:after, *:before {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
/* Font Styles */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Montserrat';
    font-size: 16px;
}
p {
    font-family: 'Montserrat';
    font-size: 14px;
}
/* Navbar Styling */
.navbar {
    font-family: sans-serif;
    padding-top: 25px;
    padding-bottom: 25px;
    background-color: transparent !important;
    -webkit-transition: 0.5s all ease;
    transition: 0.5s all ease;
}
.navbar .navbar-brand {
    font-size: 1.1rem;
    font-weight: 600;
    color: #563D7C;
}
.navbar .navbar-toggler {
    border: none;
}
/* Continue with the rest of the CSS and HTML code */
Continue with the remaining HTML code and optional JavaScript.

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

Inquiry about Tree Traversal in Javascript using Jquery

Consider the following scenario: <ul> <li>Item 1</li> <li>Item 2 <ul> <li>Sub Item</li> </ul> </li> <li>Item 3</li> </ul> This list is dynamically generated by another piec ...

Ways to condense a text by using dots in the middle portion of it

How can I dynamically shorten the text within a container that varies in width? The goal is to replace the strings between the first and last words with dots so that it fits within the container. For example, Sydney - ... - Quito. It should only replace wh ...

React Functional Component fails to update on state changes

I'm in the process of creating a React application where I can input my height and weight to calculate my BMI. The goal is to display the BMI value on a diagram. To keep things organized, I decided to break down the functionality into smaller componen ...

Shifting the entire page from left to right and back again

I am in search for a template that moves the page from left to right. If anyone can guide me on how to create this effect or provide a JavaScript example, I would greatly appreciate it. ...

jQuery random generator for creating two-dimensional arrays

Why do all rows always have the same numbers? They should be populated with random numbers. Also, how can I fix this issue? I remember seeing a solution here before but now I can't seem to locate it. var mapSizex = 5; var mapSizey = 6; var mapArray ...

The usage of 'import.meta' is restricted to within modules and cannot be utilized outside of them

I am working on a project that involves Node + Express + Babel + ES6. Within this project, I have the following files: /package.json { "name": "test-backend", "version": "1.0.0", "description": " ...

Is utilizing a standardized logging system considered a best practice for a node and express application?

I am currently working on a node.js application that consists of several dozen modules and uses bunyan for logging with JSON output and multiple configurable streams. I have been searching for good examples on how to implement a logger instance across all ...

Maya model being loaded using Three.js

I've been following a tutorial on how to load Maya models using Three.js, which you can find here. Everything is going smoothly, but the tutorial only covers loading models with a single texture. Below is the source code snippet from the tutorial: ...

Issue Encountered in NodeJS While Processing Multiple GET Requests

I have been developing a web application that utilizes a database containing game data. When a user clicks on a game, a GET request is made to an API to retrieve additional information for the selected game. My goal is to ensure that users can access detai ...

The custom filter in AngularJS fails to activate

Currently, I have a filter function that looks like this: 'use strict'; angular.module('app') .filter('fromNow', function() { return function(date) { return moment(date).fromNow(); } }); ...

Unable to dynamically display images on Vuejs carousel

I recently created a carousel using bootstrap-vue with a for loop and an array of objects to dynamically generate the components. Each slide contains text and a background image. Although I successfully rendered the text dynamically, I encountered an issue ...

React JS component experiencing issues with Material UI modal functionality

Attempting to reproduce the material ui modal example has proven to be a challenge for me. Initially, I encountered an error stating "Cannot read property 'setState' of undefined" which I managed to resolve. However, even after resolving this iss ...

The ios browser environment is unable to retrieve the value during vuejs development

When using vuejs components to create a countdown component, everything seems normal in the pc and Android environments. However, in the iOS environment, there seems to be an issue with obtaining the real count calculation as it returns NaN. <templ ...

Arrangement using the display property of inline-block not following a linear direction

I'm experiencing some issues with the arrangement of elements on this page: When the viewport width is around 800px, the layout appears misaligned. Some lines have only a few bottles even though there is space for more. Is there a solution to this pr ...

Incorporating the Acts_as_votable gem alongside Angularjs for interactive voting functionality

I'm trying to figure out how to implement Acts_as_Votable in an Angular template for a car voting system. Despite my efforts, I can't seem to display the vote count when rendering the list in Angular. I think I may need to establish some kind of ...

The challenge of vertically aligning text in a dynamically generated div

Currently, I am in the process of developing a straightforward application that allows for the dynamic addition of students and teachers. I am dynamically adding divs with a click function. To these dynamically created divs, I have assigned the class "us ...

Prevent anchor jumping caused by popstate event in Safari

This situation is really testing my patience. When navigating within the same page using anchors, the browser automatically takes you back/forward to the location of that link in your history when popstate is triggered. One might think that you could prev ...

Guide on altering the background color of a table row depending on the data in its cells with the help of AngularJS

I am looking to dynamically change the background color of a row based on specific cell data. If the first four characters in a table cell match a certain value, I want the entire row to change its color to red. Currently, my code changes the row color ba ...

Switching Between HTML Using Javascript

I am currently working on an app that allows users to easily check the local weather and temperature in either celsius or fahrenheit. However, I've encountered a problem when trying to switch between the two unit types by simply clicking on the temper ...

Why is the feedback section showing a horizontal scrollbar?

I'm puzzled as to why a horizontal scrollbar is appearing in the feedback section. I've examined the elements but can't seem to pinpoint the issue. ...