Having trouble selecting elements within the 'content' section of my webpage

I'm encountering an issue with playing a YouTube video on my website, specifically at . The video does not start and I'd appreciate assistance in resolving this. Additionally, when I set the z-index of the content division to 99, the video starts working but it causes my dropdown menu to go under the content instead of above.

var rick = false;
var audio = new Audio('rick_roll.mp3');
var kkeys = [],
  konami = "38,38,40,40,37,39,37,39,66,65,13";
$(document).keydown(function(e) {
  kkeys.push(e.keyCode);
  if (kkeys.toString().indexOf(konami) >= 0) {
    kkeys = []; // <-- Change here
    if (rick == false) {
      rick = true;
      audio.play();
    } else if (rick == true) {
      rick = false;
      audio.pause(); // <-- another issue
    }
  }
});
/*Some Fonts Here:*/
@font-face { font-family: Rusty; src: url('BrushScriptStd.otf');}
* {
font-family: Rusty;
font-weight: Lighter;
}
.background
{
background-image: url(0.jpg);
background-attachment: fixed;
background-size: 100% auto;
background-color: f7f7f7;
background-repeat: no-repeat;
background-position:absolute;
}
.menubar {
  height: 2.8vw;
  opacity: 0.85;
  background-color: #CCCCCC;
}
.clearfix:after {
  display: block;
  clear: both;
}
.menu-wrap {
  width: 50%;
  box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.2);
  background: #3e3436;
}
.menu {
  width: 100%;
  margin: 0px auto;
  text-align: center;
}
.menu li {
  margin: 0px;
  list-style: none;
  font-family: 'Ek Mukta';
}
.menu a {
  transition: all linear 0.15s;
  color: #919191;
}
.menu li:hover > a,
.menu .current-item > a {
  text-decoration: none;
  color: rgba(189, 34, 34, 1);
}
.menu .arrow {
  font-size: 0.95vw;
  line-height: 0%;
}
.menu > ul > li {
  float: middle;
  display: inline-block;
  position: relative;
  font-size: 1.2vw;
}
.menu > ul > li > a {
  padding: 0.7vw 5vh;
  display: inline-block;
  text-shadow: 0px 1px 0px rgba(0, 0, 0, 0.4);
}
.menu > ul > li:hover > a,
.menu > ul > .current-item > a {
  background: #2e2728;
}
.menu li:hover .sub-menu {
  display: block;
  z-index: 99;
}
.sub-menu {
  width: 100%;
  padding: 0px 0px;
  position: absolute;
  top: 100%;
  left: 0px;
  display: none;
  transition: opacity linear 5.8s;
  box-shadow: 0px 2px 3px rgba(0, 0, 0, 0.2);
  background: #2e2728;
}
.sub-menu li {
  display: block;
  font-size: 1.2vw;
}
.sub-menu li a {
  padding: 10px 10px;
  display: block;
}
.sub-menu li a:hover, .sub-menu .current-item a {
  background: #3e3436;
}
.Rusty 
{
font-family: "Rusty";
color: rgba(189, 34, 34, 1);
}
.content
{
opacity: .85;
position: relative;
margin: auto;
    width: 80%;
z-index: -1; 
    background-color: #CCCCCC;
    padding: 10px;
height: 100%;
}
.menu > ul > .login 
{
    position: absolute;
    top: 0;
    right: 0;
}
.video-container {
position:relative;
padding-bottom:56.25%;
padding-top:30px;
width: 100%;
}

.video-container iframe, .video-container object, .video-container embed {
position:absolute;
top:15;
left:15%;
right:15%;
width: 25vw;
height:25vh;
}
.title
{
text-align: center;
font-size: 7vh;
text-decoration: underline;
-moz-text-decoration-color: inherit;
    text-decoration-color: inherit;
}
.feed-column
{
width: 50%;
}
.text-center
{
text-align: center;
}
<html>
  <head>
    <meta name="generator"
    content="HTML Tidy for HTML5 (experimental) for Windows https://github.com/w3c/tidy-html5/tree/c63cc39" />
    <link rel="stylesheet" type="text/css" href="style.css" />
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="http://s.ytimg.com/yts/cssbin/www-subscribe-widget-webp-vflj9zwo0.css"
    name="www-subscribe-widget" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script src="script.js"></script>
    <link rel="shortcut icon" href="favicon.ico" />
    <title>RG - Home</title>
  </head>
  <body class="background">
    <div class="menubar">
      <nav class="menu">
        <ul class="clearfix">
          <li>
            <a href="aboutme.html">About Me 
            <span class="arrow">▼</span></a>
            <ul class="sub-menu">
              <li>
                <a href="#">Gaming</a>
              </li>
              <li>
                <a href="#">Programming</a>
              </li>
              <li>
                <a href="#">YouTube</a>
              </li>
              <li>
                <a href="#">Other</a>
              </li>
            </ul>
          </li>
          <li>
            <a href="schedule.html">Schedule</a>
          </li>
          <li class="current-item">
            <a href="#">
              <p class="rusty">RedstoneGaming</p>
            </a>
          </li>
          <li>
            <a href="equipment.html">Equipment</a>
          </li>
          <li>
            <a href="contact.html">Contact Me</a>
          </li>
          <li class="login">
            <a href="login.html">Login/Sign Up</a>
          </li>
        </ul>
      </nav>
    </div>
    <div class="content">
      <h1 class="rusty title">ThatRedstoneGuy&#39;s Feed</h1>
      <div class="feed-column">
        <h1 style="font-size: 3vh;" class="rusty text-center">Colortone | Am I colorblind?! | W/Voiceless</h1>
        <div class="video-container">
          <iframe src="https://www.youtube.com/embed/-egJP-2ShRk?controls=2%20align="></iframe>
        </div>
      </div>
      <div class="feed-column">
  </div>
    </div>
  </body>
</html>

Answer №1

It seems that your <body class="background"> is overlapping the .content div due to the z-index: -1; set on the content class in your css file. To fix this issue, you can simply remove it or change it to 1 and also add z-index: 2; to your .menubar class.

You can easily identify this problem using developer tools like Inspect Element in Firefox or Chrome to visualize the layout of the page as it gets rendered in the browser.

Firefox Inspect Element

Chrome Inspect Element

EDIT:

After some trial and error, I managed to find a solution. It appears that the z-index property has a correlation with whether the position is static or relative/absolute. By adding position: relative; to the .menubar class, I was able to resolve the issue and make the menu function correctly.

Answer №2

Your specified class is causing an issue, potentially conflicting with another class of the same name defined elsewhere.

To test if changing the class name resolves the problem, I have temporarily renamed it to "contents":

<div class="contents">

You can view the updated code on this JS Fiddle link.

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

What is the best way to ensure that my threejs mesh only tracks my mouse movements along the x-axis?

Trying to create a threejs mesh that responds to mouse movement by moving from side to side, but encountering an issue when changing directions. Below is the code snippet for the mousemove function: The problem arises when switching directions after init ...

How can I customize the appearance of a disabled radio button within spans?

While attempting to make my radio button square using CSS by incorporating spans and before and after elements, I encountered a new client request. The client now wants the radio buttons to be disabled with a unique style when in this state. Unfortunately, ...

Javascript code successfully executed using ajax

Using ajax, I have successfully implemented the 'addScript' function to add a js file to the loaded page. The following code snippet works perfectly: addScript('SlimBox/js/mootools.js'); However, I am encountering an issue when trying ...

Switch a Class Component to a Functional Component

Let me explain the task first and then address my problem. The goal is to incorporate a webcam component that can capture an image and then upload it with the click of a button. I am utilizing the react-webcam library, which can be found at this link: htt ...

Sharing React components in projects

Two of my upcoming projects will require sharing components such as headers, footers, and inputs. To facilitate this, I have moved these shared components into a separate repository, which has been working well so far. In the common repository, I have set ...

Tips for positioning a 404 message at the center of a webpage

Struggling with centering a 404 error message on your Bootstrap 5 page without messing up the footer layout? When the viewport is small, the 404 message may end up getting covered by the footer. Feel free to check out the code snippet in full view to see ...

Resolve the Prototype_Pollution vulnerability detected by Checkmarx

When executing the code line window.location.search.substring(1) with the word 'substring(1)', an error related to Prototype_Pollution occurs. This error is caused by assigning external properties without proper validation, which can lead to obje ...

Removing items from a list with Node.js and Express using Mongoose

Having trouble deleting elements after retrieving them from the database with mongoose. I'm unsure how to select a specific element in the list for deletion. My app features a user list with corresponding ages. Check out my userview.ejs (updated afte ...

React Alert: It is important for every child within a list to have a distinct "key" prop, not due to a missing key in the map

My current project involves developing a React 18 application. While working on one of the pages, I encountered the following error: https://i.sstatic.net/9Mk2r.png I am aware that this type of error is often linked to the absence of a unique key in the m ...

What are some tips for customizing the NavBar Bootstrap 4 Layout to fit a unique design?

Good evening everyone, I am currently working on a website project for a client who has provided me with specific requirements for the Navbar design. While it seemed straightforward at first, I have spent several hours trying to perfect the layout. I am ...

"Encountered a floating-point issue when trying to read an Excel file with

When a user uploads an Excel file that contains decimal, string, and Unicode characters, I am encountering an issue with floating point errors when reading certain decimal values. For instance, a number like 0.15 is being read as 0.150000000002 in some c ...

What is the syntax for assigning a variable name as "i" within a for loop in JavaScript?

Location data results include latitude and longitude coordinates. for(i=0; i<results.length ; i++ ){ var (marker + i) = new google.maps.Marker({ position: results[i].geometry.location, map: map }); var (infowindow + i)= new google.maps.I ...

What could be causing the hover effect to malfunction in this code snippet?

I have been working on creating a hover effect for a list of items where an underline emerges from the center. While I have done something similar in the past, there seems to be an issue preventing it from working properly this time. I have included the HT ...

Conceal a nested button depending on the value of an input field

I am facing a challenge with hiding a button inside a form. <form method="get"> <input type="hidden" name="id" value="7245"> <input type="hidden" name="action" ...

focusing on the child element of the current event's target

As I was working on a project, I came across a tab-menu jQuery plugin that needed some modifications. The issue I encountered was that the tabs were absolutely positioned, causing them to be taken out of the flow and not contribute to the wrapping div&apos ...

Tips for eliminating the shadow effect from a textbox using CSS

I need assistance with removing the shadowed edges on a textbox in an existing project. Can anyone provide guidance on how to remove this effect? Thank you for your help! ...

`Designing a UI in Ionic version 2`

Is it possible to create a layout page in an Ionic v2 application so that the navbar and sidemenu can be displayed on every page without having to add them individually to each page? For example, ASP.NET uses master pages for websites to contain component ...

In the MUI v5 framework, when using nested modals, both the parent and child modal instances will close simultaneously

Here is the reproduction of my issue on codesandbox: https://codesandbox.io/s/trusting-babbage-ovj2we?file=/src/App.js A nested modal has been created where the parent modal opens a button leading to the child modal. The useState of the parent modal has b ...

Determining when ng-repeat has completed in Angular JS

Is there a way to determine when ng-repeat has completed populating the values in the markup? Since I have numerous values, it may take some time for the rendering process. NG <ul > <li data-ng-repeat="item in values"> ...

What is the method for incorporating a 3rd party npm module without utilizing npm install?

I'm in a situation where I need to utilize an outdated 3rd party npm module that cannot be directly used with npm i and reqiure. In order to customize it for my specific needs, I have to make some modifications to the source code of this npm module. ...