Navigation Bar with a Transparent Look - background not visible

My website's navigation bar appears transparent, allowing the gradient background to show through initially. However, when I scroll, the text and images underneath become visible, which is not what I want. I would like the background to remain visible and cover over the text instead. You can view the issue on the main page here: https://gyazo.com/6c5e35ca0ed4f6f37e9e72f490737c78, and as you scroll down on these pages: https://gyazo.com/9a2957d728e36ae23e0cd9af604e8de1, https://gyazo.com/4849fb7f11689a5360e2e8686713d01d.

To achieve this effect, I believe I may need to include a block element in the HTML code that acts as a transparent layer for the background but not for the text or pictures. Please take a look at the relevant HTML and CSS code snippets below to better understand my issue.

<html>
<head>
  <title>  Moral & Ethical Issues Concerning the use of Computer Technology </title>
  <link rel="stylesheet" href="style.css">
  <link href="https://fonts.googleapis.com/css2?family=Montserrat+Alternates&display=swap" rel="stylesheet">
  <script src="jquery.js"></script>
  <script src="main.js"></script>
  <script src="smoothscroll.js"> </script>

  <body>
    <div class="main">
      <nav class="fixed-nav-bar">
            <div class="logo">
              <img src="logo.png">
            </div>
            <div class="navigation-links">
               <!-- Navigation links go here -->
            </div>
            <div class="gift">
               <!-- Gift image goes here -->
            </div>
      </nav>

For the full CSS code snippet, please refer to the original post above. If anyone has any suggestions on how to create a box around the navigation bar that shows only the background when scrolling, I would greatly appreciate your help. Thank you.

Answer №1

One way to accomplish this task is by utilizing jQuery. Through triggering a function, you can make the border of the navigation bar visible as the page gets scrolled. Below is an example code snippet showcasing how this can be implemented.


$(window).scroll(function() {    
    var scroll = $(window).scrollTop();

    if (scroll > 0) {
      $('nav').css("border","1px solid black");
    } 
});

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

Creating a dynamic text design using Bootstrap or CSS: What's the best approach?

I attempted to enable responsive font sizes in Bootstrap 4.3.1 by setting the $enable-responsive-font-sizes variable to true, but I did not see any changes. Below is the code from my template.html file: <div class="m-2" id="role" ...

JS form validation malfunctioning

XHTML <form name="suggestion" method="post" action="suggestion.php" class="elegant-aero" onSubmit="return validate()" > <label> <span>Message :</span> <textarea id="Message" name="m ...

Transitioning one element's opacity to zero while concurrently increasing another element's opacity to replace it

There are a total of 3 div elements and 3 links included in this setup. The goal is to only display one div at any given time. Upon clicking on a link corresponding to a different div, the current one should fade out while the selected one fades in seamle ...

Problems with CSS text scrolling

We have a client who wants a marquee-style scrolling text banner, and I tried using CSS animations to achieve it. However, I encountered some quirks that I'm struggling to fix. If you want to take a look at the issue, here is the link: https://jsfidd ...

What is the best way to align two navigational bars?

I'm experiencing some difficulty with positioning a second navigation bar in my Adobe XD design. View the Adobe XD design here My attempts to use the float element have resulted in an overlap with the background image for the hero section. Here is h ...

extracting the HTML content from JavaScript and saving it into a standalone file

update When I click a link, a popup opens and I see all this HTML. The smile method is called when I click the link, and we append HTML in that method so that we can see it when the popup is opened. I moved it to a separate file something.component.html, ...

Opting for HTML tags directly rather than using div.class

On my blogsite, I have implemented special tags that are designed to be user-friendly for my colleagues who may not be familiar with HTML. For instance: <question>...</question> and <answer>...</answer> These tags are then style ...

transferring information back and forth between a javascript array and php

Currently, I am developing a design website that allows users to create designs on an HTML5 canvas and save them on the server. All user information is stored in a MySQL database, while the designs are saved in a JavaScript array. My goal is to seamlessly ...

Batch download files as a zip file using JavaScript

Is there a straightforward method in JavaScript to download multiple files from URLs and save them as a zip archive? Which specific files are required for downloading in order to generate the zip file? ...

Modify the cost directly on the search results page using PHP

I am new to PHP and SQL and I have a question regarding updating the price on a search result page in PHP. I want to include an input field and a submit button that will allow me to update the price of books displayed in the search results. After submittin ...

Tips for properly formatting the data before sending it to an API

When a user submits a form, the data is sent to an API. It's important that every field appears on a new row in the output. Unfortunately, using \n and <br> inside the string does not produce the desired formatting. Can you help me with thi ...

Discovering the best locations for locating CSS color codes

I came across this question which led me to search for the color codes of green, red and yellow in decimal format for the rgba() function. According to this website, I found that green is represented by #008000, equivalent to rgb(0, 128, 0). However, I a ...

Storing executable scripts in HTML5 LocalStorage allows for the dynamic creation

As I work on a hybrid app with its own local HTML and JS files, there are times when I need to load additional small executable JS scripts and CSS from the server. Currently, I achieve this by using $.getScript, which has been working well. In order to ma ...

Retrieving Dropdown Value in Bootstrap 5: How to Obtain the Selected Item's Value from the Dropdown Button

I am having a slight issue with my dropdown button where I am trying to display the selected item as the value of the dropdown button. The Flag Icon and Text should be changing dynamically. I have tried some examples but it seems that it is not working as ...

Consider implementing a fixed position to the navigation bar

Currently, I am facing an issue with my menu layout as shown in this demo The problem arises when the menu goes outside of its container, similar to the image below: https://i.sstatic.net/nQA2K.png This issue occurs because I have applied position: fixe ...

Adjusting the transparency of a div's background using RGBa

I am currently working on adjusting the background opacity of a div using a jquery ui slider. Allowing users to modify the background color of the div, I am seeking guidance on how to adjust only the alpha parameter of the background while keeping the col ...

Scaling problem faced on iOS devices with HTML5 canvas

I've been working on a project using phonegap, trying to develop it for both Android and iOS. The main goal is to select a saved image from the phone library, display that image on an HTML img element, and then draw that img onto a canvas. Users shoul ...

An unusual CSS phenomenon with z-index

I've encountered a peculiar issue with my z-indexing. I have an image positioned relatively with a z-index of 1, and it should be above my navigation that is positioned absolutely with a z-index of -1. The problem is that upon page load, the image ap ...

The Art of Positioning Containers in CSS

I am facing some issues with my CSS. In the JSP webpage, I have a container styled with a div that works perfectly. However, when I insert another div tag to style certain elements, those elements end up outside of the container for some reason. Below is ...

Transition effects applied to images with transparency using CSS

My collection includes three transparent PNG images: https://i.sstatic.net/80Jxj.png https://i.sstatic.net/Eewcq.png https://i.sstatic.net/VXk7A.png I have arranged them using the following HTML/CSS: <div style="position: relative; left: 0; top: 0; ...