Unable to modify the background in bootstrap

I'm having trouble changing the background color or image on my website. Despite everything looking correct in my CSS, the background color just won't show.

HTML:

<!DOCTYPE html>
<html lang="en">
    <head>
        <!-- META -->
        <meta charset="UTF-8">
        <title>Boots2</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0 minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
        <meta name="description" content="">
        <meta name="author" content="">
        <!-- Slidebar -->
        <link href="css/slidebars.min.css" type="text/css" rel="stylesheet">
        <!-- bootstrap -->
        <link href="css/bootstrap.min.css" rel="stylesheet">
        <!-- Slidebar -->
        <link href="css/slidebar-theme.css" type="text/css" rel="stylesheet">
        <link href="css/main.css" type="text/css" rel="stylesheet">
        <script src="js/respond.js"></script>
    </head>
    <body>
        <!-- Navbar -->
        <div class="sb-navbar navbar-fixed-top navbar-inverse sb-slide" role="navigation">
            <!-- Left Control -->
            <div class="sb-toggle-left navbar-left">
                <div class="navicon-line"></div>
                <div class="navicon-line"></div>
                <div class="navicon-line"></div>
            </div>
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">Boots2</a>
                </div>
                <div class="collapse navbar-collapse">
                    <ul class="nav navbar-nav">
                        <li class="active">
                            <a href="#">Home</a>
                        </li>
                        ...
                    </ul>
                </div>
            </div>
        </div>
        ...

        </div>
        ...

        </div>
        
    </body>
</html>

CSS:

body {
    background-color: blue;
    padding-top: 70px;
    width: 100%;
    font-family: Helvetica, Verdana, arial, sans-serif;
}
.theme-dropdown .dropdown-menu {
    position: static;
    display: block;
    margin-bottom: 20px;
    color: #f2f2f2;
}
.theme-showcase > p > .btn {
    margin: 5px 0;
}
#top-arrow {
    padding-top: 17px;
    padding-bottom: 13px;
}

Answer №1

It seems like the issue might be caused by the CSS of the plugin you're utilizing taking precedence over your main.css styles. According to the Slidebars Github Page:

#sb-site, .sb-site-container {
/* You can now utilize the class .sb-site-container instead of #sb-site and use your custom id. However, ensure that you don't modify any of the following styles differently on your id.*/
    width: 100%;
    position: relative;
    z-index: 1; /* Site positioned above Slidebars */
    background-color: #ffffff; /* Default background color, replace this with your own css. It is recommended to transfer your html or body background styling here. Setting this as transparent will make the Slidebars below visible.*/
}

As evident from the code, #sb-site (where your actual content resides) defaults to a white background color. To resolve this, you could adjust the CSS for #sb-site in your main.css file to display as blue.

The browser tends to prioritize more specific CSS rules, with the id #sb-site being more specific than the body tag.

Answer №2

One simple solution is to enclose all of your body content within a container div and then customize the background color of this wrapper according to your preferences.

Answer №3

Although using the !important declaration can forcefully apply a style, it is advisable to use it as a last resort due to potential specificity conflicts and increased difficulty in maintaining your CSS code. It is recommended to minimize the usage of !important whenever feasible.

body {
   background-color: #fff !important;
}

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

Find the dominant color within the project's style sheets

Is there a method to extract the main color from an angular material theme and apply it in the css files of an angular project? Within a project, we can specify the primary color in a *.scss document as shown below: @import '~@angular/material/themi ...

Impeccable method to safeguard element from external css interference

Currently, I am working on a script that will be utilized across various pages and I want to ensure that the elements it generates are not affected by the CSS styles of those pages. Some individuals suggest using CSS like this: body>*{min-height:200px; ...

Struggling to input information from a web form into a MySQL database using PHP

I'm currently facing an issue with my form not being able to submit data to the MySQL database. Strangely, I'm not receiving any error messages that could help me identify the root of the problem. I experimented by changing the action method to G ...

The font color in Bootstrap is set to be lighter than the background color

Bootstrap has made great improvements in displaying navbar item colours that blend well with the background colour of the navbar. Can we apply a similar technique to body text as well? For example, if the container background is purple, can we have the t ...

What could be the reason for my submit button failing to submit data to mySQL?

My PHP form, referred to as "php1," utilizes AJAX to populate input text boxes from a MySQL database using a secondary page called "php2." The issue I am facing is that the submit button on php2 does not work properly, unless I test php2 individually. When ...

Unique ideas for organizing the layout and loading of content on my website

Last year, I created a fan site dedicated to a popular PC game, but now I feel like it could use some improvements. Currently, all the pages on my site share a common header and footer, with only the main content area changing from page to page. My curren ...

Tips for rearranging table columns using drag and drop in react js

I have been experimenting with various libraries to create a drag-and-drop feature for changing table columns order. Here is my current implementation: import React, { useState } from 'react'; import './list_de_tournees.css' const Table ...

Setting variables in AngularJS services without encountering JavaScript undefined errors

After developing an AngularJS module, I attempted to link a service and use it to share variables across the application. While most things are functioning properly, I encountered an issue when trying to set submenu[1] to an object. The error message sta ...

Guide on making a color legend with JavaScript hover effects

On my website, there is a dynamic element that displays a table when values are present and hides it when there are no values. The values in the table are color-coded to represent different definitions. I wanted to add hover text with a color key for these ...

The custom HTML menu implementation is causing the jQuery autocomplete to lose its "Select" functionality

Seeking assistance in implementing jQuery autocomplete with a custom drop down menu. I have managed to customize menu items using the data()._renderItem method (which is currently commented out), however, this approach disables the menu "Select" function ...

Adjust the Size of Bootstrap Offcanvas using CSS (Bootstrap version 5.2)

Is there a way to change the size of specific bootstrap offcanvas elements without affecting all of them? I am aware that I can modify the SASS variable ($offcanvas-horizontal-width: 400px) to change the size of all offcanvas elements. What I would like i ...

Having trouble with the side menu navigation in Bootstrap?

I have a total of 5 pages on my website. Out of these, 2 main pages contain submenus/pages as well. To make users aware of the presence of submenus, I am using plus and minus icons. However, there is an issue where clicking on one submenu toggle icon doe ...

Updating the active tab in the navigation bar whenever the router navigates

I'm struggling with changing the active tab in Angular 2 and Bootstrap 4. I have managed to get the active tab to change using this code snippet: navbar.component.html <nav class="navbar navbar-fixed-top navbar-light bg-faded"> <button cl ...

What is the process for attaching a dynamically generated object to the document's readiness event?

One of my tasks involves dynamically generating a slider element using the code snippet below: function NewDiv(){ for (var count=0; count < parseFloat(sessvars.storey_count); count++) { var string="<br><div ...

The fixed background-attachment feature does not function properly in Chrome when it is contained within a scrolling div

Essentially, if a background image is placed within a scrolling div, it will no longer remain fixed and will revert back to scrolling: CSS: <div class="wrapper"> <span></span> </div> HTML: html, body{ width: 100%; height: ...

Empower the parent container to wrap around its child elements using Flexbox

I am trying to make the flexbox parent item adjust its width based on the children, but currently it is stretching out to full width and leaving empty space on the right side. Here is the CSS code I have tried: .flexParent { display:flex; background:# ...

Adjust the background color of the header as you scroll

Seeking assistance in adjusting the background color of my header upon scrolling. This is my current implementation: header.component.ts export class HeaderComponent { ngOnInit(): void { const header = document.querySelector('.header'); ...

Utilizing jQuery's Chained Selectors: Implementing Selectors on Previously Filtered Elements

DO NOT MISS: http://jsfiddle.net/gulcoza/9cVFT/1/ LATEST FIDDLE: http://jsfiddle.net/gulcoza/9cVFT/4/ All the code can be found in the above fiddle, but I will also explain it here: HTML <ul> <li id="e1">1</li> <li id="e2" ...

How can I troubleshoot non-functional traffic lights in vue.js?

I've recently built a traffic light using vue.js, but unfortunately, it's not functioning as expected. The colors (red, yellow, and green) are supposed to change according to the time duration, but for some reason, this isn't happening. Can ...

Developing jpg/png images from .ppt/pptx files with Django

I currently have a PowerPoint file saved on Dropbox at "". My goal is to convert this presentation file into individual slide images (jpg/png..) within my Django template or using a Django def function. Once I have converted the slides, I plan to utilize ...