What is the best way to begin the main page content below the stationary header in order to prevent any overlap with the hyperlink section?

I have created this HTML page, but I am facing an issue where the hyperlinked sections overlap with the static header when clicked on. I want all linked sections to appear below the header and each section to have different dimensions within the iframe.

Is there a way to set a fixed starting point for the main content on the page so that all hyperlinked sections start from that point only?

Here is the HTML code snippet:

<html lang="en">
    <head>
    </head>
    <style>

    <!-- Styles for header and menu bars -->

    </style>

    <body>

    <!-- Main content structure with header, menus, and linked sections -->

  </body>
</html>

Illustration of the issue faced: When clicking on link2, instead of appearing just below the static header, it merges with the header section: [Image Link]

Expected behavior: [Image Link]

Similarly, clicking on link3 causes the linked section (link-3) to merge with the header section, resulting in a partial display. [Image Link]

Desired outcome: [Image Link]

Thank you.

Answer №1

I'm having trouble grasping your request, but based on what I understand, I have made some changes to the HTML 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">
    <title>Document</title>
</head>

<style>
    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    html {
        scroll-behavior: smooth;
    }

    body {
        font-family: sans-serif;
        padding: 0;
        margin: 0;
    }

    .header {
        background-color: #3A332D;
        height: 200px;
        display: flex;
        align-items: center;
        flex-direction: column;

        /*If you want the header to be sticky to top

        position: sticky;
        top: 0;
        
        */
    }

    .header h2 {
        text-align: center;
        margin: 20px auto;
        color: #ffffff;
        text-transform: uppercase;
    }

    ul {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    ul li {
        margin: 10px 20px;
        list-style: none;
        background-color: #635B53;
        padding: 10px 30px;
        cursor: pointer;
    }

    ul li:hover a {
        color: #ECEF01;
    }

    ul li a {
        color: white;
        text-decoration: none;
    }

    .video__wrapper {
        margin-top: 20px;
    }

    .video {
        width: 560px;
        height: 315px;
        margin: 20px auto;
    }

    iframe {
        width: 100%;
        height: 100%;
    }
</style>

<body>
    <div class="header">
        <h2>Result</h2>
        <ul>
            <li><a href="#link1">Link1</a></li>
            <li><a href="#link2">Link2</a></li>
            <li><a href="#link3">Link3</a></li>
        </ul>
    </div>
    <div class="video__wrapper">
        <div class="video" id="link1">
            <iframe src="https://www.youtube.com/embed/KsIDRek_Gmc" frameborder="0"
                allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
                allowfullscreen></iframe>
        </div>
        <div class="video" id="link2">
            <iframe src="https://www.youtube.com/embed/KsIDRek_Gmc" frameborder="0"
                allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
                allowfullscreen></iframe>
        </div>
        <div class="video" id="link3">
            <iframe src="https://www.youtube.com/embed/KsIDRek_Gmc" frameborder="0"
                allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
                allowfullscreen></iframe>
        </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

Assign a unique HTML attribute to a child element within a Material-UI component

Currently, I am trying to include the custom HTML5 attribute "data-metrics" in the span element within the ListItemText Material UI component. However, I am facing some difficulty achieving this as per the specifications outlined in the Component API Docum ...

What is the best way to implement the useCallback hook in Svelte?

When utilizing the useCallback hook in React, my code block appears like this. However, I am now looking to use the same function in Svelte but want to incorporate it within a useCallback hook. Are there any alternatives for achieving this in Svelte? con ...

Bootstrap dropdown feature automatically rearranges all items in my navigation bar

I recently set up a navbar for my website, but I'm struggling to grasp the concept of positioning items with Bootstrap. One issue I encountered is that when I click on the dropdown button (profile image), it causes all the items in my navbar to shift, ...

Is there a way to make text within a Div selectable even if it is positioned behind another Div with a higher z-index?

Currently grappling with some code, unfortunately cannot easily paste the problematic part here as I am unsure of its exact location. Here's the situation: there is a div containing text that needs to be selectable, however, there is another div with ...

The pop-up in the navigation bar imported from another source is malfunctioning

I'm in the process of constructing a website with a navigation bar that I'm importing from another HTML file, like this: Navbar HTML <nav class="navbar fixed-top navbar-expand-lg bg-dark navbar-dark"> <a class="navbar-brand" href="in ...

Troubleshooting an Issue with CSS Sliding Doors

I'm having trouble getting the right image to show on my website. The left side of the image is fine, but I can't figure out how to make the right one appear. As a HTML/CSS beginner, I'm still learning the basics. For more information, vis ...

Personalize the way UIkit tooltips appear

I've been working on customizing a uikit tooltip for my checkbox. I managed to change the font and background color, but for some reason, I can't adjust the font size. I even tried adding a custom class without success. Do you think it's pos ...

Utilizing ReactJS to fetch data from Material-UI's <TableRow/> component upon selection - a comprehensive guide

I've integrated Material-UI's <Table/> (http://www.material-ui.com/#/components/table) component with <TableRow/> containing checkboxes in a ReactJS project. While I can successfully select rows by checking the boxes, I am struggling ...

Adjust the size of the font based on the screen resolution

What is the best way to adjust font size based on screen resolution so that text remains as a single line when the screen is small? For example: http://prntscr.com/2qa9ze <div class="centerbreaking"> <section id="breaking-news"> <div id ...

CSS3 :target and display:none inconsistency problem in Internet Explorer and Firefox

Creating a one-page site with navigation tabs that toggle between hidden divs using :target CSS3 selector is my current project. To ensure the first div is visible upon page load, I implemented this line of code: document.location.href = "#div1"; The HTM ...

Select a specific division element using a pseudo element

My goal is to specifically target the third div in my HTML code with a class called .counter-wrap. When viewed on a mobile device, this particular div has a margin-bottom of 40px. I am looking to eliminate the margin-bottom for only the third stacked div n ...

Eliminate the horizontal scrollbar generated by a certain div

I'm working on the following HTML structure: <div id="container"> <div id="content"></div> </div> The container div is set at a width of 1050px and has a shadow background that repeats vertically. The content div is 950px ...

JavaScript form not working on submission

When my form is submitted, a function is called that successfully redirects users on desktop to either the download-confirmation or download-failure page. However, when testing on mobile devices such as iOS and iPad, the redirection does not seem to work. ...

Minimize the gap between col-lg elements in responsive mode within Bootstrap

My website is built using Bootstrap 4 and the following is the HTML code: <div class="container"> <div class="row text-center "> <div class="col-lg-6">A</div> <div class="col-lg-6">B</div> </div> < ...

Looking to extract the hidden value from an HTML input field using Selenium

Unable to retrieve the value of a hidden element in HTML, even though it is displaying. Seeking assistance in accessing the value despite the type being hidden. <input type="HIDDEN" label_value="Sub Reference" title="Sub Reference" id="ACC_NO" dbt="BK_ ...

Eliminate any undefined data in the popup map of Javascript

I am working with JSON data that is being displayed in a pop-up on a map. In cases where there is missing data (Visibility), the word undefined appears in the pop-up. Is there a way to remove the undefined text so that it does not show up in the pop-up? ...

What steps should I take to execute a unique function the very first time a user scrolls to a specific element?

The issue at hand: I am working with a sophisticated looping image carousel that needs to initiate - starting from a specified initial slide - as soon as the user scrolls to a specific division. It must not restart if the user scrolls up or down and then ...

Linear gradient background issue not functioning properly when transitioning between screens using Next.js

Encountered an unusual issue with Next.js. My background linear gradients are not loading properly when navigating between pages. The link in question is: import Link from 'next/link' <Link href='/register'> <a> click m ...

Verifying the accessibility of a website using JQuery/Javascript

I am attempting to use JavaScript to ping a website and display the result. Unfortunately, I have not had any success with this JSFiddle: https://jsfiddle.net/yyjowtru/ Although I believe I am close to achieving the desired outcome, changing the URL in t ...

A guide to placing tooltips dynamically in highcharts column charts

I am encountering an issue with tooltips in Highcharts column charts. The problem arises when the series fill up my chart, causing the tooltip to be hidden below the series and cut off by the end of the div. You can see an example here: https://i.stack.i ...