Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add background-color in a section part?

Is there any other way to add background color in section tag? Except using body {background-color: blue;}, what is are other ways to add background color into section?

I am trying to add the section background color like this:

<!DOCTYPE html>
<html>
    <head>
        <title>Testing</title>
        <style>
            #ABC {
                background-color: blue;
            }
        </style>
    </head>
    <body>
        <section id="ABC">
        </section>
    </body>
</html>

There is no color showing on my browser.

like image 704
R3y Avatar asked Aug 17 '16 09:08

R3y


People also ask

How to set the background color of a section?

The section background color you can set is based upon the main color of the theme you applied. To set the background of a section open its properties: In the properties you can define which type of section background you want to set: You need to add a supportsThemeVariants property to the manifest of your webpart and set its value to true:

What are section Background colors in SharePoint framework?

Starting with SharePoint Framework v1.8, web parts can be made aware of any section backgrounds and use these colors to improve the appearance of a web part when hosted in a section with a different background. The section background color you can set is based upon the main color of the theme you applied.

How to use a background color instead of a background image?

Alternately, you can use a background color instead of a background image. To use a background color, replace the <div> element code snippet you just created with the following highlighted <div> element code snippet like this:

How do I change the background color of a HTML page?

To use a background color, replace the <div> element code snippet you just created with the following highlighted <div> element code snippet like this: . . . <body> <!--First section--> <div style="background-color: #f4bc01; height:480px; padding-top:80px;"> </div> </body> ... Save the file and reload it in the browser to check your results.


2 Answers

Its because #ABC does not have any content or does not have a height!

See below what happened when I have set a height to it.

<!DOCTYPE html>
<html>
  <head>
    <title>Testing</title>

    <style>

    #ABC {
      background-color: blue;
      height: 100%;
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
    }

    body{
      background: grey;
      margin: 0;
    } 

    </style>

  </head>

  <body>

<section id="ABC">


</section>

  </body>
</html>
like image 132
kukkuz Avatar answered Sep 30 '22 12:09

kukkuz


<section> element is an grouping container. In your example there is no content and hence it's not visible (I have added red color border to highlight the <section>).

Highlighting the <section>:

<!DOCTYPE html>
<html>

<head>
  <title>Testing</title>
  <style>
    #ABC {
      background-color: blue;
      border: 1px solid red;
    }
  </style>
</head>

<body>
  <section id="ABC">

  </section>
</body>

</html>

Try adding height or content to your <section> for the background-color to be visible.

<!DOCTYPE html>
<html>

<head>
  <title>Testing</title>
  <style>
    #ABC {
      background-color: blue;
    }
  </style>
</head>

<body>
  <section id="ABC">
    Some text here
  </section>
</body>

</html>
like image 26
Pugazh Avatar answered Sep 30 '22 12:09

Pugazh