Ways to prevent the navbar from disappearing when the Chrome browser is resized

I am looking to align the navbar lists, which are currently on the right side, below the header icon placed on the left side. Rather than toggling the navbar with a button, I want it to simply expand under the header icon.

It seems that the disappearance is caused by the navbar-expand-lg class. Is there a way to fix this using Bootstrap alone? Or would I need to use HTML and CSS without relying on JavaScript?

HTML

<nav class="navbar fixed-top navbar-expand-lg navbar-light bg-light">
   <div class="container"> 
       <a class="navbar-brand" href="#">MADHUMITHA PRABAKARAN</a>
   </div>

   <!-- 

       <button class="navbar-toggler" data-toggle="collapse" data-target="#mainNav">
           <span class="navbar-toggler-icon"></span>
       </button>

   -->

   <div class="container"> 
       <div class="collapse navbar-collapse">
           <ul class="nav navbar-nav ml-auto">
               <li class="nav-item">
                   <a class="nav-link" href="index.html">About</a>
               </li>
               <li class="nav-item">
                   <a class="nav-link" href="portfolio.html">Portfolio</a>
               </li>
               <li class="nav-item">
                   <a class="nav-link" href="contact.html">Contact</a>
               </li>
           </ul>  
       </div>
   </div>
</nav>

CSS

.navbar{
    background: #ffffff;
    border-style: solid;
    border-color: #cccccc;

    border-width: 2px;
    border-left-style: hidden;
    border-right-style: hidden;
    border-top-style: hidden;

    top:0;

}
 .navbar-brand {
    background-color: #4aaaa5;
    color: white;
    font-size: 200%;
    font-family: 'Times New Roman', Times, serif;
    text-align: justify;
    margin-top:-10px;
    margin-bottom: -10px;
}

Answer №1

It seems like you are looking to make your <a>your title</a> act as a toggle and remain visible in all screen sizes. To achieve this, simply update the class="navbar-brand" to class="navbar-brand d-block" to override the default "display:none" of .navbar-brand in different viewport sizes. You can also apply any additional CSS styling by creating a new class like below:

<div class="navbar-brand newstyle">

Then define the styles within .newstyle { something here } in your stylesheet instead of directly modifying the navbar-brand class. This ensures that you only target specific instances of navbar-brand elements on your website.

<!DOCTYPE html>
<html lang="en>
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"><>/script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>

<nav class="navbar navbar-expand-sm">
<div class="container-fluid d-block">
  <div class="row">
    <div class="col-12">
      <a class="navbar-brand navbar-toggler d-block" data-toggle="collapse" data-target="#collapsibleNavbar" href="#">Navbar</a>
     </div>
  </div>
  <hr>
  <div class="row">
  <div class="col-12">
  <div class="collapse show navbar-collapse" id="collapsibleNavbar" aria-expanded="true"></div>
    <ul class="navbar-nav">
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Link</a>
      </li>    
    </ul>
  </div>    
  </div>
  </div>
</div>
</nav>

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

When clicking on links that are not within the ng-view element, you will be redirected to the

I'm having trouble coming up with a name for this question, but here's my current situation This is the structure of my template: ├── index.html ├── ... ├── account │ ├── index.html │ ├── authorizat ...

Having trouble finding the element for an image of a body part using xpath

When using driver.findElement(By.xpath(".//*[@id='bodyPartContainer']/div[1]")).click(); to select a part of the human body image, I'm encountering the following exception in webdriver: org.openqa.selenium.NoSuchElementException: no such ...

Utilizing Ruby interpolation to dynamically select elements in Capybara's CSS selectors

Having trouble with invalid selector errors when attempting to locate an element using capybara This method is successful: page.find("#widget_amount_Standard") But I encounter issues when trying any of the following: credit_type = "Standard" page.find( ...

Strategies for making a child div fade out when the parent div is hovered over

I have a div with the class name ordershape and inside it, there is another div called fad-res. My goal is to display the corresponding fad-res when I hover over a specific ordershape, while hiding the other divs. <div class="ordershape"> & ...

How can you easily ensure your React web app is responsive?

As I delve into building a web app using reactjs, one particular challenge I encounter is ensuring its responsiveness. An issue arises when the browser size changes, causing my components to overlap and lose alignment. Is there an easy solution to preven ...

Select Multiple Checkboxes in Bootstrap/HTML

Is there a way to make it so that selecting one checkbox will automatically select all the others in Bootstrap/HTML? ...

Refresh DataTable while making a fetch request

Here is the HTML code snippet where I want to apply DataTable: <div id="reportrange" style="background: #fff; cursor: pointer; padding: 5px 10px; border: 1px solid #ccc;"> <span></span> </div> <table id=" ...

What is the best method for effectively organizing and storing DOM elements alongside their related objects?

In order to efficiently handle key input events for multiple textareas on the page, I have decided to create a TextareaState object to cache information related to each textarea. This includes data such as whether changes have been made and the previous co ...

error: local server did not return any data

I am currently using PHP on a Linux machine. In my HTML code, I have set up an AJAX request to the local Apache server (check http://localhost), with the intention of displaying the data from the server on the screen. However, for some reason, nothing is b ...

What is the functionality of the keydown event?

Whenever the input text value is not empty, I want my .removetext div to be displayed, but it's not working correctly. When I type something after the second character, my .removetext gets hidden, but it shouldn't be hidden when the input is not ...

What is the method for showcasing an image stored in a Mysql database as a Medium Blob on my webpage?

After following instructions from the internet, I have implemented the following code in my HTML: <img src="imagescript.php?id=1"> Additionally, the imagescript.php file contains the following PHP code: <?php $servername="loc ...

How to create a looping animation effect for a div using CSS on hover

Using Bootstrap framework with Wordpress site .test { position: absolute; z-index: 9; left: 50%; height: 10em; width: 10em; margin-left: -5em; background-size: cover; opacity: 0; transition: opacity 0.5s ease; transform: translateY(- ...

Stylishly Select with Bootstrap 4

Currently, I am utilizing Angular 2 with bootstrap 4 and have implemented the following select element: <div class="form-group"> <label class="col-md-4 control-label" for="OptionExample">Choose an option:</label> <div class="c ...

Utilize JavaScript to create a toggle menu feature that can target multiple variables with just one click function

I am attempting to create a collapsing menu on click functionality with additional modifications. One of the changes I would like to implement is altering the background of another element when the menu collapses. Currently, the code snippet only works fo ...

What is the best way to toggle the navigation bar between opened and closed

I'm having trouble with this navbar not opening and closing properly. Can anyone suggest what script I should add? <nav class="navbar navbar-expand-md"> <a class="navbar-brand" href="/"> <img src=&qu ...

transitioning backwards upon the removal and addition of classes in vue

Currently, I am working on creating a help button that triggers a help-dialogue box with some animations when clicked. This is the template I am using: <template> <div class="help"> <button v-if="theme" class=" ...

navigating through tab menus based on time intervals

I'm a beginner in the world of HTML and website building. I have all my content ready to display on my site, but I'm looking for assistance in automating tab switching. Is it feasible to alternate between tabs every 5 minutes? Can someone guide m ...

the art of stacking divs with clever css techniques

As I continue to learn about the relationship between CSS and divs, I am facing a challenge with creating a blur effect that only affects the background of each rollover, not the red image overlaying it. I am unsure of the best approach to solve this issue ...

Accessing and manipulating web elements using either XPath or CSS selectors

Having trouble selecting a specific piece of information using xpath or css selector. Error messages keep appearing. Can someone help identify the issue? This snippet is from my code: output = driver.find_element_by_xpath("//td[@class_= 'sku']" ...

Strategies for avoiding overflow-x issues in Safari and mobile devices

I am currently facing an issue where I have a div containing a table with overflow enabled, allowing the whole table to be viewed by scrolling. However, on Safari and mobile Safari browsers, there is a horizontal scroll on the html and body elements. Whil ...