Utilizing Bootstrap to set a dynamic background image that spans the entire width of a table

The background image on my About page is not displaying correctly. The first < div > in my container shows it as intended, but the second < div > has white bars on the sides of the table.

As a newcomer to Bootstrap and HTML, I hesitated to seek help, but after struggling for a week without success, I am reaching out. I have attempted several solutions found on Stack Overflow and other sites with no luck. Though I can't recall everything I've tried, some attempts include placing the table in its own container, adding rows to the current container, duplicating the background image at different locations, among others. Undoubtedly, I may be making an error somewhere, and I apologize for that. Thank you for any assistance you can provide.

<body>
    <header>
        <!-- Start of Top Navbar -->
        <!-- End of Top Navbar -->  
        <!-- Start of Background Image -->
        <div class="view" style="background-image: url('/images/backgrounds/forest_sunset.jpg'); background-attachment: fixed; background-repeat: no-repeat; background-size: cover; background-position: center center;">
            <!-- Start of Unique Page Content -->
            <div class="container h-100">
                <div class="d-flex align-items-center justify-content-center h-100 align-self-center">
                    <div class="d-flex flex-column text-center">
                        <h1><strong>About</strong></h1>
                        <h4>Content.</h4>
                    </div>
                </div>
                <div class="d-flex flex-column text-center">
                    <div class="view" style="background-image: url('/images/backgrounds/forest_sunset.jpg'); background-color: black; background-attachment: fixed; background-repeat: no-repeat; background-size: cover; background-position: center center;">
                        <div class="table-responsive">
                            <table class="table table-sm" id="forest_sunset">
                                <thead>
                                    <tr>
                                        <th scope="col"></th>
                                        <th scope="col">Data</th>
                                        <th scope="col">Data</th>
                                        <th scope="col">Data</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <th scope="row"></th>
                                        <th scope="col">Data</th>
                                        <th scope="col">Data</th>
                                        <th scope="col">Data</th>
                                    </tr>
                                    <tr>
                                        <th scope="row"></th>
                                        <th scope="col">Data</th>
                                        <th scope="col">Data</th>
                                        <th scope="col">Data</th>
                                    </tr>
                                    <tr>
                                        <th scope="row"></th>
                                        <th scope="col">Data</th>
                                        <th scope="col">Data</th>
                                        <th scope="col">Data</th>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>  
            </div>  
            <!-- End of Unique Page Content -->
        </div>
        <!-- End of Background Image -->
    </header>
    <footer>
        <!-- Start of Bottom Navbar -->
        <!-- End of Bottom Navbar -->
    </footer>   
        <!-- JQuery --> 
        <!-- Popper.js -->
        <!-- Bootstrap JavaScript -->
</body> 

Here is an example of how the page currently looks. My goal is for the background to expand across the full screen width without leaving the white bars visible. It should also adapt responsively, which was my initial motivation for learning Bootstrap.

Answer №1

With this CSS, your website will adapt to any screen size and resize accordingly, making it responsive. Does this solution solve your problem?

body {
  background: url("https://images.pexels.com/photos/373912/pexels-photo-373912.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260") no-repeat center center fixed;
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

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

Learn how to retrieve JSON data from the Yahoo Finance REST API using Angular 2

Currently, I am in the process of developing an application that needs to fetch data from the Yahoo Finance REST API. To retrieve a table for the symbol "GOOG," I have implemented the following code: export class ActService{ act = []; url = 'http ...

Having trouble with callback function in Node.js npm opn package

I have been attempting to implement a callback function using the opn package (you can find the documentation here: https://github.com/sindresorhus/opn). Basically, my goal is to open a specific URL in a browser, wait for the user to close the browser, an ...

Utilizing Chessboard Positions in an if-else Statement with the Chessboard.js Library

I have been attempting to develop a function that utilizes an if-statement to verify whether a chessboard is positioned in a specific arrangement (the one I am using as the starting position) with the assistance of the chessboard.js library I experimented ...

What is the method for altering the look of a button using JavaScript?

As a beginner in web development, I have a question. Typically, I know how to style the submit button when it's created in the HTML page using CSS. However, I'm wondering if it's possible to apply CSS styling to the JavaScript block instead. ...

The error handler in AngularJS $http service is always left wanting for a call

Here's the code snippet I'm currently using: $http .post('/api/login', $scope.user) .success(function (data, status, headers, config) { // code }) .error(function (data, status, headers, config) { // code }); It seems to be functi ...

When you call setTimeout from a static function, it does not get executed

Having a problem with starting a timer in my utility typescript class. The static function initTimer() uses setTimeout but when called from a react component, the timer doesn't start. StyleWrapper.tsx const StyleWrapper: FC = (props) => { cons ...

Tips for dynamically incorporating input forms within AngularJS

I am trying to dynamically change the form inputs using ng-bind-html. However, I am only able to display the label and not the text box on the DOM. The content inside ctrl.content will depend on the values received from the server. Important Note: The ...

The schema encountered an error due to the absence of the save method

My current goal is to allow a logged in user to visit any user's URL and follow them. However, I'm encountering an issue: TypeError: Object { _id: 54bd6b90b7d4cc8c10b40cbd, name: 'Johnny', username: 'batman', __v: 0, ...

Choosing items in CSS

Here is a piece of HTML code to work with: <body> <pre class="typescript"> <span class="classDecl"> <span class="statement">export</span> <span class="keyword">class</span> ...

The moving div suddenly halts before continuing its journey

Two overlapping divs create an interesting sliding effect. A gray div slides in from the top over a black div. Hovering your mouse over the black div causes the gray one to slide out of view. If you hover over the gray div, it also slides out but pauses ...

ReactJS how to prevent accordion from collapsing automatically

My custom accordion layout for the features needed in the site I am building is not working well with Jquery. How can I modify it to collapse properly? Specifically, I want it so that when I open number 2, number 1 will automatically close. I've trie ...

I am unable to locate the type definition file for 'core-js' at the moment

Currently, I am in the process of developing an application using angular2 along with angular-cli. Surprisingly, angular-in-memory-web-api was not included by default. In order to rectify this, I took the initiative to search for it and manually added the ...

vue v-if="canEdit" @click.prevent

I have a Vue component called 'test' with specific template and methods. The goal is to make the div clickable only if helper.isEditable is true, otherwise it should be notClickable or touchable. However, I can only retrieve the value of helper. ...

Combining arrays in JavaScript to form object values with lodash

In my current project, I am attempting to manipulate JavaScript object arrays using lodash. The goal is to stack array values from different objects and map them to corresponding objects in a new array. Here's an example of what I'm working with: ...

Error encountered while routing in Node.js

Apologies for the basic nature of this question, but I find myself unable to resolve it on my own. I am currently developing an application that will send messages based on a specific parameter in Json. Below is an excerpt from my app.config.json file: & ...

What is the best way to ensure that a parent element with a nowrap property can inherit the width of

It's proving difficult for me to make a parent element inherit the width of its children. Here is the link to the jsfiddle http://jsfiddle.net/4mk3S/ Currently, I only have an outer div with white-space: nowrap; and child divs with display ...

Discovering all class names following the same naming convention and storing them in an array through Javascript

Hey everyone, I could use some assistance with a coding challenge. I'm aiming to extract all class names from the DOM that share a common naming convention and store them in an array. For instance: <div class="userName_342">John</div> & ...

Using JQuery to verify if a certain letter or word has been entered by the user in a textarea

Can anyone assist me in checking if a user has entered a specific letter or word and, if correct, display a button? I would appreciate any guidance! Here is my current code snippet: $(document).ready(function() { $(".textArea").keyup(function() { ...

What is the process for modifying the headers of a post request in Express when

I have a Node/Express application and I'm looking to incorporate an image upload feature into an order form. While I can successfully use the action link in the HTML form to perform a POST request, I also want my JavaScript file associated with this ...

Issues with relocating function during the NgOnInit lifecycle hook in an Angular 2 application

Currently, I am facing an issue with my Angular 2 app where the data sometimes lags in populating, causing a page component to load before the information is ready to display. When this happens, I can manually refresh the page for the data to appear correc ...