The anchor is ineffective (directs to the # but stays in place)

Every attempt I've made to find a solution online has failed. When I hover over the link, it directs me to the correct URL, but the page doesn't move. I'm using an up-to-date version of Chrome.

Below is the code snippet:

Edit: It seems that the issue is related to the CSS, as removing the CSS code made it work. However, the exact reason behind this behavior is still unknown.

$('.scroll').localScroll();
body {
  margin:0;
  color: #222;
  background-color: #222;
  font-family: 'Work Sans', sans-serif;
  font-weight: 400;
  overflow-y: scroll;
  overflow-x: hidden;
}

html, body {
  width: 100%;
  height: 100%;
}

.container{
  width: 80%;
  margin: 0 auto;
}

header::after{
  content: '';
  display: table;
  clear: both;
}

#down{
  filter: brightness(0) invert(1);
  width: 3%;
  height: auto;
  position: absolute;
  top: 50; bottom:0; left: 0; right:0;
  padding-bottom: 20px;
  margin: auto;
}

.movetobot{
  height: 200vh;
}

section h1{
  color: #fff;
  position: absolute;
  text-align: center;
  top: 110%;
  width: 100%;
  line-height: 0.4em;
  font-family: 'Roboto', sans-serif;
  font-weight: 300;
}

.center{
  text-align: center;
}

header {
  width: 100%;
  height: 100vh;
  background-attachment: fixed;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;

}

.logo {
  color: white;
  float: left;
  font-family: 'Roboto', sans-serif;
}

.btext{
  font-family: 'Roboto', sans-serif;
  color: #f9f3f4;
  position: absolute;
  text-align: center;
  top: 40%;
  width: 100%;
  line-height: 0.4em;
}

h1{
  font-size: 50px;
}

.btn{
  color: #fff;
  font-family: 'Roboto' sans-serif;
  font-weight: 300;
  text-decoration: none;
  border: #ccc 1px solid;
  padding: 10px 15px;
  border-radius: 8px;
  line-height: 4em;
}

nav {
  float: right;
}

nav ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

nav li{
  display: inline-block;
  margin-left: 85px;
  padding-top: 25px;

  position: relative;
}

nav a {
  color: white;
  text-decoration: none;
  text-transform: uppercase;
}

nav a:hover {
  color: #ecf0f1;
}

nav a::after{
  margin-top:5px;
  content: '';
  display: block;
  height: 5px;
  width: 0%;
  background-color: black;
  position: absolute;
  transition: all ease-in-out 350ms;
}

nav a:hover::after {
  width: 100%;
}

.btn:hover{
  color: #b19295;
  border: #fff 1px solid;
}

::-webkit-scrollbar {
  width: 10px;
}

/* Track */
::-webkit-scrollbar-track {
  background: #f1f1f1;
}

/* Handle */
::-webkit-scrollbar-thumb {
  background: #888;
}

/* Handle on hover */
::-webkit-scrollbar-thumb:hover {
  background: #555;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8>
  <link href="https://fonts.googleapis.com/css?family=Roboto:100,300" rel="stylesheet">
  <link href="css/hover.css" rel="stylesheet" media="all">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <link href="css/hover.css" rel="stylesheet" media="all">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <link rel="icon" href="/icons8-home-24.png">
  <title>Royal Services</title>
  <link rel="stylesheet" href="style.css">
</head>

<body>
  <div id="first">
    <div class="container">
      <a href="index.html"><h2 class="logo">R O Y A L</h2></a>
      <nav class="scroll">
        <ul>
          <li><a href="index.html">Home</a></li>
          <li><a href="#services">Offering</a></li>
          <li><a href="https://discord.gg/tmkjepT">Contact</a></li>
        </ul>
      </nav>
    </div>
    <!-- <hr width="100%"> -->
    <a href="#services">
    <img src="https://d30y9cdsu7xlg0.cloudfront.net/png/634848-200.png" alt="down" class="hvr-hang" id="down">
  </a>
    <div class="btext">
      <h1>ROYAL SERVICES</h1>
      <a href="https://discord.gg/tmkjepT" target="_blank" class="btn">Discord</a>
    </div>
  </div>
  <div id="services">
    <section class="movetobot">

      <h1>Services</h1>

    </section>
  </div>
</body>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-scrollTo/2.1.2/jquery.scrollTo.min.js"></script>
<script src=https://cdnjs.cloudflare.com/ajax/libs/jquery-localScroll/2.0.0/jquery.localScroll.min.js></script>
<script src="js.js"></script>

</html>

Answer №1

To relocate the content, assign the unique identifier "id" to the tag of the page section you wish to move.

<a href="#someUniqueId"></a>
<div id="someUniqueId"></div>

Answer №2

The reason for this issue is that the content inside the <div id="first"> is either floating or positioned absolutely, causing the div to have no height. As a result, the

<div id="services">
takes up the entire page. This is why when you click the link, the page is already loaded.

To fix this problem, you can add a min-height property to the <div id="first">. Alternatively, I recommend restructuring the HTML in a more organized manner and removing any floats or absolute positioning.

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

Transform HTML or formatted text from an iPhone 4 Notes backup SQLite file into plain text

I was looking to recover some missing notes from an iTunes backup of an iPhone 4 by accessing the notes.sqlite file. After querying the table that stores the note text: select zcontent from znotebody I found that the text is in HTML format. Is there a wa ...

Modifying the image height in a column using Bootstrap and JSON data

My webpage is dynamically generating images from a JSON file through a JavaScript file. However, the images are displaying at different heights, and I want each column to adjust to the height of the image to eliminate any gaps. Particularly, data with the ...

Discovering the clicking actions on PDF elements within an HTML environment

I am currently working on developing a web application that involves rendering various pdf objects. My main goal is to be able to detect the position of a click inside the pdf container. However, it seems like the OnClick event is not functioning as expe ...

What is the best way to prevent handleSubmit from triggering a re-render when moved to a different

Just started experimenting with React and ran into an issue that I can't seem to find a solution for anywhere. I have a basic search form that interacts with an API. If an invalid value is returned, it displays an H3 element with an error message lik ...

What is the best way to implement a dialog box that displays a website within it, all while keeping my SharePoint site running in the background?

For a while now, I've been working on SharePoint Online and trying to troubleshoot an issue without success. That's why I'm considering starting over with a specific section of my SP site from scratch. My current project involves creating a ...

Unable to expand Bootstrap navbar due to collapsing issue

I recently implemented a collapsed navbar on my website using bootstrap. However, I'm facing an issue where it does not open when clicking on the hamburger menu. After researching various solutions for this problem and trying them out, none of them s ...

Hamburger Icon in Bootstrap Navbar-Brand is not aligned as expected

I'm currently working on a website project using Bootstrap and have encountered an issue with the navbar component. When the screen shrinks to the breakpoint I've defined (lg), the alignment of the hamburger icon gets disrupted, as shown below. ...

Tailwind CSS - when it comes to styling, larger screen media queries are taking precedence over smaller media queries

Currently tackling screen responsiveness issues in a Nextjs + Tailwind CSS project. All Tailwind breakpoints are functioning correctly except for "sm" and below. Snippet of the problematic code: <div className="bg-red-200 sm:bg-white md:bg-gray-70 ...

Content within the Iframe is in the process of loading, followed by

Exploring the code below: <iframe id="myframe" src="..."></iframe> <script> document.getElementById('myframe').onload = function() { alert('myframe is loaded'); }; </script> Is it a possibility that the ifra ...

Incorporate a local asciinema file into an HTML document

Is there a way to embed a local asciinema session into an html file? Here is how my directory is structured: $ tree . ├── asciinema │ └── demo.cast ├── css │ └── asciinema-player.css ├── index.html ├── js │ ...

Centering text in a D3 donut chart

Struggling with centering text inside a d3 donut chart for a project. While trying to modify a piece of code, I find myself lost in the complexity of it. Despite my efforts, the text added to the center is not perfectly centered. I have attempted various ...

Adjust the Weight of a Single Word in H1 CSS

I've been trying to figure out how to achieve the following for a while now. I know I can solve this issue by using different h1 tags and positioning them separately, but I'm curious to find out if there's a way to do it without dividing the ...

Discover the key steps to extracting codes within a string in React or Javascript

I am currently developing an application that could potentially receive a string from the backend server. The string might look something like this: If you were to fold a piece of paper in half 50 times, its width would be three-quarters of the distance fr ...

Tips for wrapping text to fit the width of a column

Hello, I have a table with varying column widths as shown below ${"#goldBarList"} table tr td:first-child{width:5%;} ${"#goldBarList"} table tr td:first-child+td{width:5%;} ${"#goldBarList"} table tr td:first-child+td+td{width:6%;} ${"#goldBarList"} table ...

Insert a variety of pictures into divs that share the same class

Can I target div elements with the same class in CSS and apply unique styles to each? Here is my HTML: <div class="image"><br/>a</div> <div class="image"><br/>b</div> <div class="image"><br/>c</div> ...

When adjusting the top margin of the main content in CSS, the fixed top navigation section's margin also decreases simultaneously with the main content

I am in the process of creating a basic static blog page using HTML5, SASS, and CSS. While working on the design, I utilized the 'nav' semantic element for a fixed top bar on the page that remains visible even when scrolling down. Additionally, ...

Error Encountered in jQuery UI SelectMenu

Struggling to integrate the jQuery UI SelectMenu, I keep encountering the same error in the browser console. Below is the HTML Code: <select name="files" id="files"> <optgroup label="Scripts"> <option value="jquery">jQuery.js</ ...

Enhancing a character's appearance with custom CSS styling

In my code, I want to highlight a single character throughout the page. I want the lines between each word to be a different color from the rest of the text using CSS, without having to add span tags to each one individually. Anti-virus End Point | Dis ...

The functionality of the localStorage HTML5 feature is experiencing issues within the WebView on Samsung Android devices

I am currently facing an issue with my HTML5 application which I am wrapping with a WebView. In order to store and retrieve user input values between pages, I have been utilizing the localStorage feature in HTML5. Interestingly, this feature functions per ...

CSS creates gaps between each of the internal elements inside the HTML document

I'm looking to create a 4px space between all internal components within my HTML, regardless of direction (top, bottom, left, or right). I have attempted to achieve this by using an external CSS file with the following code: body { padding: 2p ...