Essential Theme Block Heading Background Colour

Re: Essential Theme Block Heading Background Colour

by Mary Evans -
Number of replies: 5
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

OK, well if it helps, the Essential theme paints every block white, whether you want it white or not.

The css used is this...

.block { background: white;}

To disable this you need to add this CSS...

.block { background: none;}

To disable that background and also add a new color you need to do this:

.block { background: none; background-color: #eeeeee; } or whatever colour code you prefer.

Cheers

Mary

Average of ratings: Useful (2)
In reply to Mary Evans

Re: Essential Theme Block Heading Background Colour

by Zeid Fanous -

Hi Mary, 


I am trying to change colors of 4 different html blocks using their instance id...i followed your steps but i cant get it to change color ... can you please help... ? anyting else i should add???


I am using Moodle 3.1 with Adaptable theme.

#inst133.block_html.block.header {
        background-color: #890;
}


Thanks 



In reply to Zeid Fanous

Re: Essential Theme Block Heading Background Colour

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

You are adding too many things together...so try this instead:

#inst133.block_html .header {
        background-color: #890;
}

Notice the .header is separate and NOT connected like you wrote it.

Hope this helps?

Mary

Average of ratings: Useful (1)
In reply to Mary Evans

Re: Essential Theme Block Heading Background Colour

by Zeid Fanous -

I dunno what to say,


you're awesome ...thank you so much...


but can you explain to me the separation in .header for future reference

In reply to Zeid Fanous

Re: Essential Theme Block Heading Background Colour

by Richard Oelmann -
Picture of Core developers Picture of Plugin developers Picture of Testers

The separation relates to how the classes are in the html.

If the classes are on the same object, then there is no gap eg. the css for

<aside id="inst4" class=" block block_navigation  card m-b-1" aria-labelledby="instance-4-header" data-block="navigation" role="navigation">
could be written as
.block.block_navigation.card {css_rules:here;}

But if you are specifying selectors from different levels inside a 'parent' such as

<aside id="block-region-side-pre" class="block-region" data-droptarget="1" data-blockregion="side-pre">
<a class="sr-only sr-only-focusable" href="#sb-1">Skip Navigation</a>
<aside id="inst4" class=" block block_navigation card m-b-1" aria-labelledby="instance-4-header" data-block="navigation" role="navigation">
<div class="card-block">
<h3 id="instance-4-header" class="card-title">Navigation</h3>

Then your css might be written
.block-region   .block.block_navigation.card   .card-block   .card-title {css_rules:here;}

where the css selectors from different levels of the html are separated, but the css selectors that relate to the same html element are not.

Hope that helps
In reply to Zeid Fanous

Re: Essential Theme Block Heading Background Colour

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Zaid,

You need to be familiar with both HTML and CSS to really understand this, but generally speaking you do not need to connect all CLASSES to an ID unless targeting a specific element, or because they already exist in a stylesheet and you want to customise that particular element.

In your case...

The HTML mark-up for that block will be something like this...

<div id="inst133" class="block-html block">
    <div class="header>
        <div class="title">
            <h2>...</h2>
        </div>
    </div>
</div>

As you can see the ID in this case in CSS is written as #inst133 and also has two classes attached to it. In CSS these are written as

  1. .block-html
  2. .block.

In this case you do not need both of these classes, in fact you should not need any as #inst133 is unique and so will work on it's own.

Notice, however, that the next <div class="header"> is not included here as that falls beneath in a separate division of it's own. And that is the reason for the separation in the final CSS..

#inst133.block_html .header {
        background-color: #890;
}

Hope that helps with your learning?

Cheers

Mary