Issues arise when attempting to make the background image in Bootstrap collapse responsive

Whenever the screen size changes in my code, the collapse icon appears. However, when I click on that icon, none of the contents are visible.

Another issue I am facing is that I want the background of the section element to be an image. So, I added a background-image property in CSS but it doesn't seem to be working as expected.

body { 
padding-top: 70px; 
}
.navbarhead{
background-color: #BDBDBD;

height: 100px;
border-style: solid;
border-right: none;
border-top: none;
border-left: none;

}

#navitem{
font-size: 20px;
color: black;
}

.btn-small{
padding:10px 25px; 
}

#btnin, #btnin:hover,#btnin:focus {
color: #fff;
font-family: 'open_sanssemibold';
font-size:20px;
background-color:black;
text-decoration:none;

}

#btnup, #btnup:hover,#btnup:focus {
color: black;
font-family: 'open_sanssemibold';
font-size:20px;
background-color:white;
text-decoration:none;

}
<!DOCTYPE html>
<html lang="en">
<head>
<title>ShortFundly-LeaderBoard</title>
<meta http-equiv=X-UA-Compatible content="IE=edge">
    <meta name=viewport content="width=device-width, initial-scale=1.0">
    <!-- Viewport Meta Tag -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
    <link rel="stylesheet" href="css/bootstrap.css" media="screen">
    <!-- Style sheet -->
    <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css" media="screen">
    <link rel="stylesheet" type="text/css" href="css/leaderboard.css" media="screen">
    <link rel="stylesheet" type="text/css" href="css/leaderboard-responsive.css" media="screen">
</head>
<body>

        <!--navbar starts-->
        
        <nav class="navbar navbar-toggleable-md navbar-light bg-faded fixed-top navbarhead">
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="true" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse in navbar-collapse" id="navbarTogglerDemo01">
                <a class="navbar-brand" href="https://www.shortfundly.com">
                    <img src="https://www.shortfundly.com/tpl/main/v4/images/logo.svg" class="img-fluid" alt="Shortfundly Logo" />    
                </a>
                <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
                    <li class="nav-item" id="navitem">
                        <a class="nav-link" href="#">Community</a>
                    </li>
                    <li class="nav-item" id="navitem">
                        <a class="nav-link" href="#">Collaborate</a>
                    </li>
                    <li class="nav-item" id="navitem">
                        <a class="nav-link">LeaderBoard</a>
                    </li>
                </ul>
                <ul class="nav navbar-nav navbar-right my-lg-0 m-0">
                    <li><a href="" class="btn  my-sm-0 my-2 btn-lg"                           id="btnin">sign in</a></li>
                    <li><a href="" class="btn  my-sm-0 btn-lg m-4"                             id="btnup">sign up</a></li>
                </ul>
            </div>
        </nav>
        <!--navbar ends-->
        
        <!-- HEADING STARTS -->
        <section style="background-image: url('banner.png');margin-top: 100px;">
        <div class="container">
            <div class="Jumbotron">
                <h1>My Jumbotron</h1>
                <p>Think BIG with a Bootstrap Jumbotron!</p>
            </div>
        </div>
        </section>
        
        <!--HEADING ENDS-->
       
</body>
</html>

image source: imgur.com/CE0Fm.jpg

Answer №1

To ensure Bootstrap works properly, it is essential to include both jQuery and bootstrap.js scripts in your HTML section.

<script src="https://code.jquery.com/jquery-3.2.1.min.js"

integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous">

Answer №2

Ensure that all the necessary Bootstrap 4 CDNs are included in your project. It seems like you're missing some essential JavaScript files.

<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>

Additionally, it would be advisable to remove height: 100px; from your .navbarhead in your CSS to ensure proper display of the collapsed menu.


Consider adding styles to your .navbar-brand at the breakpoint for collapsing. For very small screens, removing margin from your login buttons could improve the layout. Although using !important is not recommended, it may be necessary for specific scenarios when overriding styles.

@media screen and (max-width: 992px) {
  .navbar-brand {
    align-self: flex-end;
    margin-top: -2.5rem;
  }
  .m-4 {
    margin: 0 !important;
  }  
}

Take a look at the: CodePen Demo

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

Is there a setting causing Webpack to not rebuild when there are changes to the CSS?

I have configured postcss-loader and style-loader on webpack, and I am using webpack-dev-server. However, every time I make changes to the CSS, webpack does not rebuild automatically. The script for webpack dev server that I use in npm scripts: webpack-d ...

When you hover, a panel will slide in from the right. When you move the mouse

Hey everyone, I've been trying to implement the solution provided but I seem to be missing something. Can you take a look at my fiddle? http://jsfiddle.net/cancerian73/Ej5k8/ body { position: relative; min-height: 3000px; margin: 0; padding: 0; to ...

Unable to conceal tab content upon clicking the identical tab

I recently implemented a tab system with panels that seems to be working well when switching between tabs. However, I'm facing an issue where clicking on the same tab does not hide the corresponding panel and reset the aria attributes as intended. I&a ...

Steps to create a translating floating chat button on your website

Hello there! I am attempting to replicate the style of a Floating Website Chat Button. When a user clicks on the large button, I want it to disappear and transform into a chat box. Something similar to this example: https://codepen.io/neilkalman/pen/VPJpaW ...

Generate several div containers that occupy the entire screen

I'm struggling to design a one-page website with full-screen divs, but I can't seem to make them truly full screen. This is my first time using Bootstrap for responsiveness, and I want the background video to remain fixed while the divs take up t ...

Is it possible to access the HTML template prior to Outlook applying any additional classes during rendering?

I recently received an email template created in a different platform via Outlook. I am attempting to recreate this email in the Salesforce Marketing Cloud Platform, but I am encountering numerous unnecessary tables, classes set by Outlook (MsoNormal, Ms ...

Is there a way to create a table that has varying columns for each row?

I am currently working with bootstrap4 and I am trying to create a table that has 3 columns in the first row and 4 columns in the following two rows. I want it to look like this: https://i.sstatic.net/nuI55.png Here is my existing table: <link href ...

Unable to mark checkboxes in Bootstrap 4 Dropdown (triggered by vue.js) due to unresponsive behavior

When using Vue.js to open a Bootstrap Dropdown, I encountered an issue with selecting custom checkboxes within the dropdown menu. I have come across information about event.stopPropagation() potentially causing this problem, but I am unsure where to imple ...

What causes the sub-menus to move even when they are set to position: absolute?

The sub-menu items under the about link appear to be slightly shifted from the left, despite setting it with position: absolute; left: 0px. I aim to have all menu items (including sub-menus) perfectly overlapped. Below is the code snippet: <html> & ...

Can you show me the procedure for retrieving a particular element with selenium? (Page Source provided)

Disclaimer: I must admit that my knowledge of HTML and CSS is minimal, so please bear with me! Hello everyone, I am attempting to utilize selenium[Java] to browse a website and retrieve a file. While I managed to successfully get past the login page, I fi ...

Tips on creating horizontally aligned buttons with full width

Currently, I am facing an issue while attempting to create three equal-sized buttons laid out horizontally. However, what I have accomplished so far is displaying three full-width buttons stacked vertically. Here's the code snippet: <section class= ...

Is it possible to place content at the bottom of a div using just a single div element?

Here is the css I am currently using: .stage{ width:960px; background-image:url('stage.png'); background-position:bottom; background-repeat:repeat-x; min-height:400px; float:left; text-align:center; } This code place ...

python selenium style attribute for element

There is a snippet of HTML that resembles this: <a class="" data-style-name="Black" data-style-id="16360" "true" data-description="null"<img width="32" height="32" I am trying to extract the text "Black" from it and then click on it. However, there ...

Is it recommended to apply the ARIA directory role to a breadcrumb navigation list?

Currently, I am working on enhancing the accessibility of a breadcrumbs component that is structured around a <ul> element. In my quest for solutions, I came across the concept of ARIA roles and specifically the directory role. While it seems like a ...

Display an icon to act as a separator between icons in CSS styling

Is there a way to display a spacer line before and after icons (cross symbols) while excluding the spacer line before and after buttons carrying the word "Cancel"? How can this be achieved? This is my CSS file: .Container > *:first-child::before, .Con ...

"Crafting a sleek card design using Material UI components in React JS

Exploring the world of material UI and looking to create a card with an image and footer. However, I'm facing challenges as there is no default option for adding a footer in the card. https://i.stack.imgur.com/xlxyb.png I want the image to be center ...

Aligning a badge to the right in Bootstrap 4 modal-header

I'm struggling to make the "Banana Score" badge float to the right in Bootstrap 4. Is this even possible? I've experimented with various flex variations, and the best I could come up with was using columns as a workaround, but it looks worse tha ...

The webpage is completely blank, displaying only a stark white screen

After designing a website, I encountered an issue where upon opening it in the browser, it only shows a blank white page. I am puzzled as to why this is happening. Could you please take a look at this link and assist me? Thank you in advance. ...

Animating with React using the animationDelay style does not produce the desired effect

Is there a way to apply an animation to each letter in a word individually when hovering over the word? I want the animation to affect each letter with an increasing delay, rather than all at once. For example, if scaling each letter by 1.1 is the animatio ...

Several target elements on a single page

I am currently facing a problem with maintaining the active state of one anchor tag's target while clicking another button within the main identifier. Upon clicking the INTEL button, its opacity changes from 0 to 1. However, upon clicking Data Histor ...