Unable to add a colored background in React Bootstrap with ease

Hey everyone, I'm currently working on an app using react-bootstrap and I've run into a problem with styling the footer. When I try to add a background color to my footer using the * tag, it ends up affecting all of my components rather than just the footer component. Can anyone offer some guidance on how to solve this? Any help is greatly appreciated.

Here's my code:

import '../styles/Footer.css'
import {Row, Col} from "react-bootstrap"

const Footer = () => {
    return (
        <>
            <Row>
                <Col md={12} lg={4} className= "footerleft">
                    <img alt="Logo  Hotel"></img>
                </Col>

                <Col md={12} lg={4} className= "footermid">
                    <h3>Contact Info</h3>
                    <hr></hr>

                    <p>Email:
                    </p>
                </Col>

                <Col md={12} lg={4} className= "footerright">
                    <h3> Follow Us</h3>
                    <hr></hr>

                    <a><img src="" alt="Facebook Logo"></img></a>
                    <a><img src="" alt="Instagram Logo"></img></a>
                </Col>
            </Row>

            <div className="copyright">
                <hr></hr>
                <p>
                    Copyright © 2014
                    <br/>
                    All Rights Reserved
                </p>
            </div>

        </>
    )
}

export default Footer

This is my Footer.css file:

*{
    background-color: blue;
}
.copyright{
    text-align: center;
}

.copyright hr{
    color: #967A50;
}

Answer №1

To achieve this, you can create a class and assign the desired color to it.

return (
    <div className="footer">
        <Row>
            <Col md={12} lg={4} className= "footerleft">
                <img alt="Logo  Hotel"></img>
            </Col>

            <Col md={12} lg={4} className= "footermid">
                <h3>Contact Info</h3>
                <hr></hr>

                <p>Email:
                </p>
            </Col>

            <Col md={12} lg={4} className= "footerright">
                <h3> Follow Us</h3>
                <hr></hr>

                <a><img src="" alt="Facebook Logo"></img></a>
                <a><img src="" alt="Instagram Logo"></img></a>
            </Col>
        </Row>

        <div className="copyright">
            <hr></hr>
            <p>
                Copyright © 2014
                <br/>
                All Rights Reserved
            </p>
        </div>

    </div>
)

For the CSS part, update the styling like this:

* {
    background-color: blue;
  }

Change the above code to:

 .footer {
   background-color: blue;
 }

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

A method for displaying information in HTML by implementing ng-repeat in AngularJS

I have retrieved JSON data in my controller as a response and now I need to display it in the HTML. Here is what I have implemented: Inside my controller: .controller('DataImportControl', ['$scope','$http', '$location& ...

Display a React div element if the loop was found to be empty

I am working on rendering a list and need to display a message if the data was not loaded successfully. Below is a snippet of my code: <div className="dashboard-table dashboard-table-done"> <div className="dashboard-table-title dashbo ...

Bootstrap transitioning to a new line when reaching the medium breakpoint

Is there a way to adjust the following HTML code so that the columns break to a new line at the md breakpoint and below, instead of at the md breakpoint and up? <div class="w-100 d-none d-md-block"></div> ...

Using conditional statements in CodeIgniter to display various menus

I encountered an issue with a variable in my code. When I attempt to retrieve its value, it shows up as undefined despite having stored the session of the variable "$level" and passing it to the view. I find it strange that the condition of the variable tu ...

Troublesome situation arising from CSS floats overlapping div elements

It's strange how this issue always occurs when using floats. This is what my div (samle) looks like: <div class="main> <div class="inn_div">&nbsp</div> </div> Here is my stylesheet: .main{ width:250px; border:1px ...

React, Storybook - Error TS2307: Button module not found or its type declarations. Can Storybook resolve this issue?

In my React project, I have a Button component created with "create-react-app" that uses absolute paths for importing. When trying to import { Button, ButtonProps } from 'Button', I encountered an error with TS2307. The absolute path 'Butto ...

Can you explain how TypeScript determines the intrinsic attributes in React?

Many questions on SO seem to be talking about errors related to matching with type 'IntrinsicAttributes' For instance, when trying to pass a prop like <Greet foo="hello" /> to a component without defining it in the component prop ...

I encountered an issue when trying to run the npm start command. Can anyone help

I have encountered some errors in my React project and attached an image. Can someone guide me on how to resolve these issues? I am new to React and struggling with this. ...

Adding a custom source to the script tag in Angular 7

I am currently using angular cli to develop my web application. The app is being built in the dist folder as of now. This is the index.html file: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Adm ...

Utilize jQuery to trigger PHP validation script

HTML Code: I have implemented validation using jQuery. My next task is to call a PHP file from jQuery, perform validation in page2.php, and then submit the data to the database. After successful submission, I need to redirect to index.php. However, I am f ...

MUI: Autocomplete received an invalid value. None of the options correspond to the value of `0`

Currently, I am utilizing the MUI autocomplete feature in conjunction with react-hook-form. I have meticulously followed the guidance provided in this insightful response. ControlledAutoComplete.jsx import { Autocomplete, TextField } from "@mui/mater ...

Show the current status of an API call in React using TypeScript

As a beginner in React and TypeScript, I'm working on calling a Graph API using POST method. Below is my code snippet: const OwnerPage: React.FunctionComponent = () => { const [TextFieldValue, setTextFieldValue] = React.useState('& ...

Leveraging JSON data with nested menus in Material UI frameworks

I am currently facing an issue with binding data to the MenuItems at the nested menu level. While I can successfully map the data to populate the main levels, encountering errors with the submenus. Here is a snippet of my JSON: const languages = [ { ...

It seems that in Laravel 5.3, it's challenging to add a script to a view for an autocomplete

Currently, I am working with Laravel 5.3 for my internship. However, I have encountered a frustrating issue that I need help with: I am trying to implement an "autocomplete" field on a page, but it doesn't seem to be functioning correctly. The error ...

The div smoothly descended from the top of the page to the center under the control of jQuery

I am trying to implement a feature where a div slides down from the top of the page to the center when a button is clicked. However, my current code seems to be causing the div to slide from the bottom instead of the top. Ideally, I want the div to slide ...

Converting Epoch time to date in NextJS

In my NextJS app, I have a date displayed in a div. <div>{post.createdat}</div> The date is shown in epoch time (1609553315666), indicating the number of seconds that have elapsed since 1970. I'm wondering if there's a way to conver ...

The combination of eq, parent, and index appears to be ineffective

Okay, so I have this table snippet: <tr> <td> <input type="text" name="value[]" class="value" /> </td> <td> <input type="text" name="quantity[]" class="quantity" /> </td> </tr> Here& ...

Assigning a value from a .CTP template to a .JS file

Have you ever encountered a perplexing and frustrating issue? :x Let's dive into it: So here's the situation - I have a specific software deployed across 4 different environments: Development, Certification, Preproduction, and Production. Rece ...

Profile picture in perfect proportion

Have you ever wondered how Facebook maintains the proportions of your profile picture? Is there a special algorithm in place? I've observed that the maximum width of the profile picture div is set to 180px, and the height adjusts proportionally to the ...

Manipulating DOM Elements with the Style Attribute in JavaScript

I am faced with two different blocks of code: var holder = document.createElement('div'); var a = document.createElement('div'); a.style.float = 'left'; a.style.width = '90px'; a.style.height = '90%'; a.s ...