Create a stylish header image that partially overlaps a fixed navigation bar, complete with functional buttons

Within the layout, there are two primary components: the 'header image' and the 'navbar'. The image is set to overlap the navbar partially by adjusting the margin.

In its default state, this configuration functions properly due to an undisclosed technique. Despite the image overlapping the navbar, the links within the navbar remain functional in areas where the image is transparent.

However, when the navbar becomes fixed (using position:fixed after scrolling, via the affix plugin), this workaround ceases to be effective and the navbar ends up covering the image. The HTML code is as follows:

<div class="container brand-img-container">
   <img class="brand-img" alt="" src="IMAGEWHICH OVERLAPS PARTIALLY" />      
</div>   

<div id="nav-wrapper" class="container">
<div class="row">
    <div id="nav" class="navbar navbar-static span4">
        <div class="navbar-inner">
                <ul class="nav pull-left">

                    <li><a href="anypage">Button</a></li>
                </ul>
        </div>
    </div>
</div>
</div>

<div class="container">    
   <h2> R <h2>    
</div>         

The CSS code is as follows:

#nav.affix {
 position: fixed; 
 top: 0; 
}

.brand-img-container {
  position: relative;
  margin-bottom: -80px;    
 }

You can view an example with a base64-encoded picture here: http://jsfiddle.net/5qYK8/9/

When attempting to adjust the z-index, the image completely covers the navbar, even in the default scenario, rendering the links non-operational. You can view this behavior in the following link: http://jsfiddle.net/5qYK8/8/

Is there a way to allow the image (specifically the red cross) to overlap the navbar in both fixed and unfixed scenarios while keeping the Button functional? Can anyone provide insight into why the Button works in the first case despite being overlapped by the image?

Answer №1

Since there is a rollover image covering the navigation link, you will need to create a separate transparent link within a fixed <div> using the same jquery script. This new clickable area will allow users to access the link even when the image is present.

To achieve this, create another <div> container and enclose an <a> tag around a <div>, like so:

<div id="toplayer">
    <a id="nav1" class="link" href="#"><div class="inner"></div></a>
</div>

Additionally, you must duplicate the selector ID below and give it a unique name according to your needs. For example:

#nav1.affix {
    position: fixed; 
    top: 0; 
    z-index: 0;
}

Ensure that your CSS has a higher z-index value than the div containing the image. In the provided example, the background is blue for visibility during testing.

#toplayer{position:relative;width:85px;height:40px;}
.inner{width:85px;height:40px;background:blue;}
.link {width:85px;height:40px;}

Here is a jsfiddle demonstration with a blue background to showcase the functionality. Alternatively, here is a version without the blue background for reference on appearance.

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

Enhance Fullcalendar by incorporating an HTML tag alongside the "titleformat" option

I am utilizing the jQuery Fullcalendar agenda feature. My main objective is to link an action with each date that appears in the calendar and enable the opening of a separate window for each date. Therefore, I am looking to include a button or a link next ...

I'm experiencing issues with my custom CSS file conflicting with Bootstrap

It's strange, my custom main.css doesn't seem to have any effect on changing the font size or location of the text. However, as soon as I remove the line that links to bootstrap, it starts working perfectly. I believe that the bootstrap.css file ...

Purchasing a Checkbox alongside its corresponding label

I have been working with the Oracle CPQ tool and am faced with the challenge of creating a checkbox attribute within it. Upon inspecting the UI, I came across the following: https://i.sstatic.net/xE5aH.png Upon examining the browser source code (generat ...

In order to design a v-btn-toggle with vertically aligned buttons, rather than horizontally

I'm currently in the process of developing a quiz using VueJS and Vuetify. My challenge lies in organizing the answer options vertically for the user to select. I attempted to utilize the v-btn-toggle component, but encountered an issue where the butt ...

Positioning div at the top of the body section

Presently, I have this specific designhttps://i.sstatic.net/U4IT4.png The issue I am facing is with the alignment of the jumbotron (boostrap v5). It is currently centered, but I would like it to be positioned at the very top of the body. I have experiment ...

Enable only a single radio button to be selected in HTML

I am facing an issue with my radio buttons where I only want one to be selected at a time. Despite giving them the same name, all four can still be selected simultaneously. <h1>Portion</h1> <input type="radio" name="portion_n ...

Utilize CSS Module class names through direct DOM access

I have a unique situation involving a component that utilizes CSS-Modules through the babel-plugin-react-css-modules plugin. During certain points in the component's lifecycle, I need to calculate new dimensions by directly accessing the DOM. Within ...

The issue of HTML5 video not playing in IOS 8 WebApp (webview) is a common problem that many users

I am experiencing an issue with a simple HTML5 video playing on Safari browser. After adding it to the home screen as a Standalone WebApp, the video no longer functions properly. This problem seems to have occurred when transitioning from iOS7 to iOS8. &l ...

Issue with accessing hamburger menu on Bootstrap site

I recently added a navigation bar to my website using the BootStrap documentation. However, when I switch to the mobile version and click on the hamburger menu, nothing happens. Below is the code snippet for reference: <nav class="navbar navbar-expand- ...

Django and Pure CSS are used to create a unique radial timer

After successfully creating a 5-minute radial timer using pure CSS, I've begun my journey with Django. I'm eager to explore whether I can take this timer to the next level and make it functional for all users who visit my page. Is it possible for ...

Using JavaScript to print radio type buttons

Currently working on a web page and I've encountered a problem that's got me stumped. There are two sets of radio buttons - the first set for package dimensions and the second set for weight. The values from these buttons are assigned to variable ...

Tips for spinning the background of a button without rotating the button itself

I'm encountering an issue while trying to rotate the background-image within my button. Instead of showing the specified background image, only the background color is visible. The photo includes a transparent section to achieve an arch-like appearanc ...

Incorporate various style components to enhance the appearance of an item in ExtJS

I'm attempting to add ellipsis to an item created by ExtJS. My goal is to only modify this item without adding any additional CSS files. After researching, I discovered there is a "style" parameter that accepts CSS styles and attempted the following: ...

Elevating the Sidebar: Transforming Bootstrap 4 Sidebar into a Top

Recently, I delved into the topic of creating a responsive sidebar menu in Bootstrap 4. After exploring various solutions, I opted for an alternate version. Here's the HTML code snippet that I implemented: <div class="container-fluid"> < ...

Background image on webpage failed to load

I've encountered an issue with a background image I downloaded for my website - it simply will not display. Here is the CSS code I am using: background-image: url(Resources/Icons/background-image.jpg); background-attachment: fixed; Even after tryin ...

Display a progress bar in Bootstrap with a labeled indicator positioned above the bar and background to the

Is there a way to create a progress bar with a label positioned to the right using Bootstrap v5.2 Progress Bar? https://i.sstatic.net/gOWie.png I attempted to use negative margins to achieve this layout but faced issues when the label expanded due to lon ...

Executing the command in the Windows Command Prompt by utilizing an HTML button

When a button on my HTML page is clicked, I want to execute the command python abc.py in the Windows command prompt. The python file is stored at C:/abc.py. I'm looking for guidance on how to code the HTML page to achieve this functionality. Any assis ...

How can the issue of the background fill option covering multiple loading bars be resolved?

I am currently relying on Google Translator, so there may be errors in the translation. The issue I am facing is that when I add a parameter with the "fillColor: '#f4f5f9'", the wheel covers one of the elements of Multiple Bars. I have modified ...

Mastering the art of designing responsive blocks with solely CSS and HTML

Verify: I am interested in designing a responsive layout as illustrated below: Desktop View: https://i.sstatic.net/vzSpz.png Mobile View: https://i.sstatic.net/0a8Q5.png To achieve this design, I have implemented the following CSS and HTML structure: ...

Is it possible to merge elements into a carousel in the mobile display?

I have a collection of elements that I would like to combine into a swipeable carousel. Is there a way to achieve this, specifically to make it a carousel only in mobile view? If needed, here is the HTML code. Thank you for your assistance. <div class= ...