Change background color div

Asked

Viewed 3,746 times

2

I’m trying to change the background color of div with the classes wrapper row-offcanvas row-offcanvas-left , but I’m not getting it.

Would anyone have any idea how to do?

  • already tried to put the "Important" in front, example: background-color: red ! Mportant;

  • 4

    Enter the code for a better analysis :)

  • 2

    Renan edits your question and asks what you have of HTML and CSS code if you used something other than the original Bootstrap. Just asking like that can’t help you

2 answers

0


There are some cases that even using the ! Important, the new application does not work. They are cases like:

Another class using ! Mportant:

In this case only check the layout of the classes, for example, wrapper row-offcanvas row-offcanvas-left, the last style application will be from the last class, so if you have:

-- bootstrap.css

.wrapper{
    color: #ffffff;
}

.row-offcanvas-left{
    color: #000000; //está cor será aplicada
}

But should the class wrapper has the !important it will be applied. And if the two classes have the !important to row-offcanvas-left will be applied. But supposing your class row-offcanvas-left is using Important but is not working.

Application of the file call:

If you have a style.css file and another bootstrap.css file, when this file is called the result is also changed. For example, if you have the class row-offcanvas-left in both files, the file that is called last, will be the style applied:

--- index.html

<link rel="stylesheet" href="bootstrap.css">
<link rel="stylesheet" href="style.css"> //arquivo que sera aplicado o estilo

--- index.html

<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="bootstrap.css">//arquivo que sera aplicado o estilo

This is due to the way the . html and . css files are interpreted by the browser. As if you were reading a book, from left to right, from top to bottom.

0

Add a new class to your div for example <div class="background"> And in the CSS code do so.

<style>
  .background{ background-color: blue; }
  // Caso não funcione adicione o !important no final do css
</style>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.