When I apply position: absolute; to my navigation bar, the anchor tags and links do not seem to function properly, especially with a video playing in the background

How can I make my anchor tags/links work properly on a header with a video in the "background" and a menu on top?

HTML

<nav class="menu">
      <a href="#" target="_blank">ABOUT</a>
      <a href="#" target="_blank">PRICES</a>
      <a href="#" target="_blank">CONTACT</a>
    </nav>

<div class="video-container">
      <video class="video-tablet" autoplay loop>
        <source src="videos/SampleVideo_720x480_1mb.mp4" type="video/mp4">
        <source src="videos/SampleVideo_720x480_1mb.webm" type="video/webm">
        Your browser does not support the video tag.
      </video>
    </div>

CSS

.video-tablet {
    display: flex;
    width: 100%;
}

.menu {
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    padding: 1%;
    position: absolute;
}

.menu a {
     color: white;
     font-size: 20px;
     font-weight: bold;
}

.menu a:hover {
     color: #559565;
}

Answer №1

The issue you're facing is that your video element is positioned in front of your navbar. This means that when you try to click on the navbar, you end up clicking on the video instead. To resolve this problem, you need to ensure that the navbar appears in front of the video by adjusting the stacking order using CSS and setting the z-index property:

.video-tablet {
  display: flex;
  width: 100%;
}

.menu {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  width: 100%;
  padding: 1%;
  position: absolute;
  z-index: 1;      /* Ensure .menu appears above other elements */
}

.menu a {
  font-size: 20px;
  font-weight: bold;
}

.menu a:hover {
  color: #559565;
}
<nav class="menu">
  <a href="#" target="_blank">ABOUT</a>
  <a href="#" target="_blank">PRICES</a>
  <a href="#" target="_blank">CONTACT</a>
</nav>

<div class="video-container">
  <video class="video-tablet" autoplay loop>
    <source src="videos/SampleVideo_720x480_1mb.mp4" type="video/mp4">
    <source src="videos/SampleVideo_720x480_1mb.webm" type="video/webm">
    Your browser does not support the video tag.
  </video>
</div>

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

Alter the Default Visibility on an HTML Page from Visible to Hidden with JavaScript

I found this code snippet on a website and made some modifications. On my webpage, I have implemented links that toggle the visibility of hidden text. The functionality is working fine, but the issue is that the hidden text is initially visible when the p ...

Getting data from non-input fields in Flask

Seeking some guidance here - struggling to figure out how to extract values from elements other than input fields using Python with Flask. For instance, I'm working with an HTML form containing the following elements: <form action="/newgame" metho ...

Aligning a rotated paragraph in the middle of its parent container

Here is my current progress: http://jsfiddle.net/2Zrx7/2/ .events{ height:100px; position: relative; } .tt_username{ position: absolute; top:0px; height: 100%; width: 30px; background: #ccc; text-align: center; } .tt_usern ...

Creating SVG paths using coordinates for THREE.js

I copied the exact code from this ThreeJs Example designed for generating a three-dimensional City Model. I've created an SVG path outlining city boundaries using Google Maps and now I'm trying to use the above code to create a similar 3D object ...

Exploring Style Attribute Manipulation using vanilla JavaScript on Firefox

I searched for a similar question, but I couldn't find anything quite like it. I'm currently developing a JavaScript Slider plugin for various projects within our company. This requires me to manipulate styles on certain elements in the DOM. I&a ...

Customize CSS styling

When it comes to the styling of my first line, I have a specific style in mind: * { text-align:left; } This style works well across most parts of the site as they are predominantly left aligned. However, there are few areas where I need the text alig ...

Embedding a compact table using HTML on the sidebar

I am facing a challenge in this HTML code where the table appears next to the spans. How can I make sure that the spans appear below the table instead? <div> <table align="right"> <tr> <td>smthg</td> ...

Positioning a single column of iframes in the center

I have 6 graphs that I need to arrange in a grid with 2 rows and 3 columns. Each row should have one left-aligned graph, one center-aligned graph, and one right-aligned graph. However, the center-aligned graphs are not displaying correctly. Can someone hel ...

How do I switch back and forth between displaying content as 'none' and 'block' using JQUERY?

Take a look at this code snippet. <div class="sweet-overlay" tabindex="-1" style="opacity: 1;display: none;"></div> Is there a way to switch the style attribute value from none to block and back? ...

Content will not be visible within the HTML template

While attempting to incorporate an HTML template I discovered online, everything seemed to be functioning correctly except for the fact that the text was not appearing. Following a tutorial required me to use a static file to load the site. Another issue I ...

How can you assign a strokeStyle color to a Canvas using a CSS property?

Our team is currently working on an Angular2 / Ionic 2 project where we have implemented a HTML Canvas element that allows users to draw on it. One challenge we are facing is how to set the Canvas strokeStyle property using a color provided by a CSS style. ...

Tips for creating a responsive ReactJS website with Material-UI

I've been working on a reactjs project with material-ui, and everything looks great on desktop. However, when I switch to the mobile layout, all the text and images start overlapping. I'm wondering how I can make my site responsive. Below you&apo ...

Tips for overlaying text onto a MaterialUI icon

https://i.stack.imgur.com/cFr5Y.pngI am currently working on a project that requires me to overlay a number on top of an icon. Specifically, I am utilizing the MaterialUI ModeComment icon and attempting to display text over it. Despite trying the following ...

How can I show the localStorage value in an HTML5 template using Angular2?

I have two keys stored in localStorage and I want to display one of them on my template. I'm having trouble accessing these values. I even created an interface specifically for storing the value of the currentUser key from localStorage. How should I g ...

Add a variety of input values to a div in designated spots

Objective: The aim is to allow the user to connect form fields with specific locations within a content from another div, and then add the text entered in individual input fields to those corresponding locations. Here is the link to the fiddle HTML: < ...

Center a span vertically inside a div as the text within the span grows to occupy the entire div

I am facing an issue with a table that has 25 td's. Each td contains specific elements as shown below: <td> <div> <span> text </span> </div> </td> Additionally, there is a script in place that adj ...

Wrapbootstrap offers dynamic design options for Java-based web applications

I recently obtained a bootstrap theme from the website wrapbootstrap to use in my Java web application. However, I am unsure of where to begin with it. Despite having already added the bootstrap css to my application, I now wish to remove it and replace it ...

Spacing between products in Woocommerce product list

Welcome to my website! Check it out here: I am facing an issue with a long margin at the bottom of my woocommerce product list. I have tried using CSS to change it as shown below: .woocommerce .products ul, .woocommerce ul.products { margin-bot ...

Issue with parallax scroll feature on Mobile Safari not functioning as expected

I created a JavaScript code for parallax scrolling on an image at the top of a webpage. The code functions perfectly on Chrome, Firefox, Internet Explorer, Opera, and Safari on desktop. However, when I tested it on Safari on my iPad, the parallax effect wa ...

Move to the right with floating using Angular Material

I am dealing with a situation in which I have an md-card-content element. Inside it, there is a div and another md-card-content element. The challenge I am facing is that I want to move the contents of the inner md-card-content to the right. I tried usin ...