The issue with Smooth Scroll not functioning arises when the height of both the html and body is set to 100%

html, body {
   height: 100%;
   min-height: 100%;
   position: relative;
}

#home {
   height: 100%;
   background: url("../img/test.jpg") center no-repeat;
   background-size: cover;
}

I've incorporated the Smooth Scroll JavaScript by CSS-Tricks

$(function() {
  $('a[href*=#]:not([href=#])').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
        }, 1000);
        return false;
      }
    }
  });
});

On my webpage, the initial section displays a full-page image. To achieve this, I set the html and body heights to 100%, which also applies to #home. However, I encountered an issue where the Smooth Scroll effect stopped working when the html and body have a height of 100%. Removing the height property from the html and body elements allowed the Smooth Scroll effect to function properly.

Has anyone else faced a similar problem?

Answer №1

Replace height: 100% with min-height: 100%.

Answer №2

Check this out for some valuable information. Great resource!

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

Combine JavaScript and CSS in an ASP.NET website, not a web application

I have the following set up: There is a Class named BundleConfig located in the App_Code Folder Imports System.Web.Optimization Public Class BundleConfig Public Shared Sub RegisterBundles(bundles As BundleCollection) bundles.Add(New ScriptBundle( ...

Emulate the CSS hover effect with jQuery 코드 희미한

Is there a method in jquery or any other technology that can detect event X and trigger a different event elsewhere? Currently, I am working with an image that has an image map. When a user hovers over a specific area on the map, I would like another part ...

Create a feature that allows users to easily copy text with

Looking to utilize this Bootstrap code for generating an address and adding copy button functionality: <div class="modal fade" id="bitcoinModal" role="dialog"> <div class="modal-dialog modal-lg"> <d ...

Creating a webpage with a form is a simple process that involves utilizing both PHP and HTML

Just like creating a post in WordPress or asking a question on this website, I am curious about how to create a page simply by filling out a form. I understand how to build an HTML form, manage data in a database, and have some knowledge of PHP. However, ...

Issue with populating dropdown menu inside jquery modal dialog box

When I click on the 'create new button', a modal window form pops up with a dropdown menu. The dropdown is supposed to be populated via ajax with the help of the populateUserData() function. Even though the ajax call seems to be successful, I am ...

Customizing the color of a select dropdown in Bootstrap using CSS styling

I am having difficulty changing the default blue color for Bootstrap select dropdowns. Despite trying :hover and :active selectors on both option and select, I have not been successful in making the desired changes. Could anyone provide insight regarding ...

AngularJS animation fails to activate

I've been working on a simple AngularJS application and I'm trying to add animations between my views. However, for some reason, the animation is not triggering despite following the tutorial on the AngularJS website. There are no errors in the c ...

Expanding the clickable area of a link using the CSS :before pseudo-element selector

I am currently working on a project involving an image slider and I am facing a challenge with the "previous" and "next" arrows. My goal is to have each arrow occupy half of the slider area, but adjusting padding or margins tends to change their position o ...

Error 500: Issue with JQuery AJAX File Upload

Hey there, I'm facing an issue with doing a file upload using JQuery's AJAX feature as I keep getting the error 500. $(function() { $( 'form' ).submit ( function() { $.ajax({ type: &a ...

Utilize API or alternative methods for analyzing Instagram data

My master's thesis requires me to dissect multiple Instagram profiles, each containing over 1000 posts. I am in need of a comprehensive list including the following details: Type of Post (Image, Multi Image, Video) Description Likes Comments (total c ...

Review and add alt attributes to images that are missing them

I have a plan to create a Java tool that can evaluate HTML pages on an existing website. The goal is to add the alt="" attribute to any image that currently lacks it. One idea is to use an HTML parser, such as HtmlCleaner, to generate a DOM structure of th ...

Storing an object in ajax.py using Dajax/Dajaxice with specified parameters

After successfully setting up and running all examples on dajaxproject.com, I am now facing challenges in using the knowledge gained for a more complex scenario. My goal is to pass multiple parameters to the ajax function, including text from a form, in or ...

Having trouble extracting the date modified from a JSON file

I am able to retrieve section name, URL, web title, and headline from parsing JSON data with this code snippet. However, I seem to be encountering an issue where I cannot extract the last modified date. Here is the JSON structure: { "response":{ ...

Utilize $stateParams to dynamically generate a title

When I click a link to our 'count' page, I can pass a router parameter with the following code: $state.go('count', {targetName: object.name}) The router is set up to recognize this parameter in the URL: url: '/count/:targetName& ...

Guide on how to make an ajax request using expressjs with the "PUT" method

When submitting a form, I am processing it for an AJAX call. For express.js to support other HTTP verbs, the form must include <input type="hidden" name="_method" value="put"> Despite setting the AJAX call to type: "PUT", I keep receiving a 404 ...

Complete the submission of a form containing a dropdown field

I'm looking to accomplish a seemingly simple task, but I'm unsure how to do it: Within my table of records, I want to include a select field that displays different views based on the selection. Here's an example of what my select field loo ...

Can angular $q.all() achieve the same level of success as jQuery $.get()?

Upon reviewing the jQuery documentation, I discovered the following: $.get( "example.php", function() { alert( "success" ); }) .done(function() { alert( "second success" ); <--- }) .fail(function() { alert( "error" ); }) .always(fun ...

Modify the background color of a particular TD element when clicking a button using JavaScript and AJAX

When I click on the "Active account" button inside the designated td with the <tr id="tr_color" >, I want the value "1" to be added to the 'active_account' column in the database. I have been successful with this functionality. However, I a ...

Using jQuery to determine if the mouse is currently hovering over a specific element

Dealing with binding a mouseenter event in a deferred function: $(window).load(function(e) { var $container = $('.container'); $container.mouseenter(function(e) { //do something }); ... }); A common issue arises when the mouse is al ...

Javascript data table pagination and custom attributes resulting in unexpected truncation of strings

Currently, I have implemented an Ajax functionality in my template to receive a JSON response and dynamically populate a datatable with the elements from that JSON: $('.bicam_tests').click(function(){ $.ajax({ type: 'GET', ...