Clear space in navigation bar

Is there a way to create a space on the navigation bar where the current tab is selected without making it the same color as the background?

In other words, I want the "My Page" tab (currently selected) to be transparent, but still show the background color instead of blending in with the navigation bar's color behind it.

Answer №1

Ensure to include an empty element to make this function. Confirm that none of the previous elements to your navigation section have a different background than the one you want visible behind your tab.

body {
    background: #F58B73;
}

.nav-links {
    display: table;
    width: 100%;
    table-layout: fixed; /* could use `white-space: pre` instead */
}

.nav-button {
    display: table-cell;
    width: 140px;
    height: 30px;
    padding-top: 10px;
    padding-left: 20px;
    background: #231F20;
    color: #FFFFFF;
    text-decoration: none;
}

.spacer {
    background: #231F20;
    width: 100%;
    display: table-cell;
}

.nav-button-selected {
    background: transparent;
}

        <div class="nav-links pull-right">
            <div class="spacer"></div>
            <a href="#" class="nav-button nav-button-selected">Who I am</a>
            <a href="#" class="nav-button">What I do</a>
            <a href="#" class="nav-button">How to contact me</a>
        </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

Tips on enhancing the appearance of your numberbox with vibrant colors

Hello everyone! I am working with some devextreme code blocks and need help in changing the border color of a numberbox to red. Can anyone guide me on how to achieve this? import React, { useState } from 'react'; import { NumberBox } from 'd ...

Enhancing Layouts with Bootstrap 5: Implementing Space Between Rows

Can anyone help me figure out how to add a vertical gutter between two rows with Bootstrap 5? I've tried using g-* and gy-*, but as shown in this jsfiddle, it doesn't seem to be working. Any ideas on what might be causing this issue? From my und ...

Is there a way to show a completely different webpage when someone accesses it from a mobile or tablet device

When a user accesses the website from a large screen device like a computer or smart TV, it will display controls optimized for that specific screen resolution. Conversely, when the user uses a mobile device to surf the same page, the controls will adjus ...

Image pop-ups that overlay text on the homepage

I'm facing an issue and I'm looking for a solution... Upon entering my homepage, I would like to display a popup image showcasing a new event so visitors can see it before accessing the website. I attempted to achieve this using JavaScript but w ...

Which component from the Bootstrap library would be best suited for my needs?

I am looking to create a basic 6-page website. Here is the code for my main page: <html> <style> .ali{ width:170px; text-align:center; } footer{ background:#333; color:#eee; font-size:11px; padding-top: 25px; p ...

Issue with Bootrap 4.1.1: Banner image and navbar are not extending to full width

I recently created a new page using Bootstrap 4.1.1, but I'm having trouble getting the banner image and navbar to stretch the full width of the page. You can view the live page here. Can someone help me pinpoint what's wrong in my code? I'v ...

Moving the webpage into the realm of mobile and tablet devices

Over the next few weeks, I will be working on transitioning my website content to have both a mobile and tablet version. During this process, I have some questions: What is the best way to redirect users to the correct site based on their device/browse ...

I have tried implementing "display:inline-block" but my DIV stubbornly refuses to stay on the same line

I need to align two block elements horizontally, one being a FORM and the other a DIV. <div id="miningArea"> <form id="curWorkForm">...</form> <div id="buttonDescription"> To start, click the "Start" button. < ...

What is the best way to link text to an image using JavaScript?

I have a query that I need some assistance with. I've developed a random image generator which is working fine so far: var randPics = document.querySelector("#randPics"); var getPics = document.querySelector(".getPics"); getPics.addEventListener( ...

Issues with Read More/Less functionality on a website - Troubleshooting with JavaScript, jQuery, and Bootstrap 4

I'm looking to create a simple, lightweight feature where clicking on a "read more" link will reveal a paragraph, and then clicking on a "read less" link will hide it again. My knowledge of JS and JQuery is quite limited. I'm currently utilizing ...

Utilizing JavaScript Files Instead of NPM as a Library for Open Layers: A Step-by-Step Guide

I've been attempting to get Open Layers to function in my Eclipse web development environment, but I've encountered some challenges along the way. The setup instructions provided on the Open Layers website focus mainly on using npm. Nevertheless, ...

Creating inline form groups within a form

Hey there! I'm looking to align the divs with class="form-group" so that their labels are on top, rather than inline with the fields. Currently, they are stacking on top of each other like this: https://i.sstatic.net/rNoS3.jpg I want them to appear ...

Achieving uniform row height in CSS Grid Layout

How do I ensure all footers with a green background have the same height, while also keeping the content height consistent? Current result: https://i.sstatic.net/SrgFq.png Desired output: https://i.sstatic.net/4cr25.png CodePen: https://codepen.io/yas ...

I need to figure out how to nest a div inside of a ul-li-a and ensure that the text inside the

In my search button, I have a cached list of options. When I select one, it should trigger the menu and choose the correct option. However, I am having trouble comparing the innerText of a div with the selected option from the search area. Both a and div e ...

Issues with Height Directives not Being Followed by Bootstrap 4

I am facing an issue with my web layout where I have two elements that are supposed to occupy 25% and 75% of the screen height using Bootstrap 4's row directives. However, it seems like these directives are not affecting the height of the elements as ...

PHP dropdown menu is a dynamic feature that provides users

Can anyone help me identify the issue with this code? I am struggling to display the sub menu... I suspect the problem lies in the section where I retrieve the sub menu from the database. However, upon inspection, everything seems correct... It's po ...

Tips for vertically centering a span within a div that is floated to the right

Need help centering a span vertically within a div when using float:right? <div class="card"> <div class="card-header"> <h5>TEST</h5> <span class="fa fa-info"></span> </div> <div class="card-body" ...

The appearance of the logo varies across various web pages on the site

Isn't it strange that my logo appears pixelated only on the home page, even though I used the same HTML and CSS code for all pages? The Html: <a href="Home.html"><img id="logo" src="../CONTENT/Images/Logo/1Sr2l8а.png" alt="logo"/></ ...

Container-wrapper unable to contain images, overflowing despite using overflow:hidden property

I am currently working on a unique section for a website that includes a .container-wrapper element consisting of text and multiple images. The container is set to have overflow: hidden; in order to prevent any overflow issues. However, the images within t ...

Choose from a variety of video play options

Being new to javascript, I've successfully combined two functions that control video playback, but they seem to be conflicting with each other. The first function is designed to offer custom pause and play controls for the video // VIDEO CONTROLS STA ...