Create a banner image

Required: page specific .SCSS file, .jpg banner (1300px x 325px)

To create your banner image, first you must make sure you have a custom .scss file for your page specific style. see page styles

in your page specific style, you need to define the banner class

[class&"__banner"]{

}

Q: What is this doing?
A: The & on this class selector, is telling the CSS to look for any DOM element within the page you have specified that contains "__banner".

You then need to define the banner image. This must have a background-size of "cover" so that it will always be full width and centered to the containing element

[class&"__banner"]{
    background: url('/Content/images/banners/[image].jpg') no-repeat center center;
    background-size: cover;
}

Thats the CSS. Now for the HTML

The banner gets added before the <section class="main__content">.

<section class="main__banner">
    <div class="banner__content">
        <h1 class="banner__title">How To Create a banner image</h1>
    </div>
</section>
<section class="main__content">

The banner will be overlayed by the main content and the title pushed up.

Create a new .SCSS file

When creating a new .SCSS file, you need to make a decision on where it belongs. Variables, Mixins, Includes or Pages.

Once you have decided where it belines, create your .SCSS file in there

The file name must be prepended with an underscore "_". This will stop it being compiled as its own .CSS file.

Once the file has been created, for it to be compiled in with the main CSS, it needs to be included in styles.scss

Open styles.scss and in the top of the file, there will be all the other includes. You can include it in the specified area there

DO NOT place it some where random in the files, or include it in a sub file else where. The files must be included within styles.scss so that the other things such as variables and mixins can be hierarchically trickled down through the include structure.

Create page specific styles

To create your page specific styles, you need to first create your .SCSS file. - see Create a new .SCSS file

At the start of your page specific styles, you need to define your <body> class. - see bodyClass for more information

You define your class like so:
.directory__filename

If however, you would like to assign styles specifically to a group of pages (lets say, the profile page for example) you can define just the class directory.

Example:
Each page will have a body class of "profile__[pagename]".
We can use the ^ in CSS to tell it to "select the body where its class starts with 'profile__'"

body[class^="profile__"] {

}

You can then next your page specific CSS within this, and continue to your hearts content.

Clear Floats (clearfix)

No longer do you need to create a random DOM element to clear floats. The time has come where we can simply rethink how it works!

What we will do instead is imagine that the floating objects just need to have a wrapper around them to tell its containing element to hold them properly, like a box.

so you can now just add a class of "group" to a containing dom element.

Q: What is this doing?
A: I'm glad you asked! What this is actually doing is creating a pseudo element of ":after" at the end of the dom element.

Example:

.group:after {
    content: "";
    display: table;
    clear: both;
}

for more information CSS tricks - Clearfix

Use Calc (with and without the mixin)

calc() is your life saver with CSS - you want a 4 column layout with margins? Use maths! width: calc(25% - 10px);

However... some bundlers and SCSS dont work nicely together, and don't like calc() as a whole, so it breaks. There are some work arounds, but basically you need to add some extra stuff in to make it work

default: calc(25% - 10px)

You convert it to a string by wrapping it in ~"". This then becomes
string: ~"calc(25% - 10px)";

Q: What is the bundler doing?
A: The bundler is minifying the code, and removing the space between the % and the equation. This then This then gets rendered as
render: calc(25%- 10px);
which breaks in Chrome. (for some reason, IE is fine with this...)

So to fix this issue, we need to wrap the % sign in ()'s to make it work. This then becomes
Final product: ~"calc((25%) - 10px)";

Q: Ok, so were good now?
A: WRONG! - the bundler doesnt care about you, and if you want to make maths with a "+", then it removes the space again... doesnt care about the ()'s. This then becomes
strong: ~"calc((25%)+ 10px)";
which breaks in Chrome. (for some reason again, IE is still fine with this...)

Q: This sucks... how do we fix it?
A: Well, we need to turn that frown, upside down! ... by hitting it with a double negative. This then becomes
Final Final product: ~"calc((25%) - -10px)";

or...

We just use the mixin i made, and just type .calc(@param, @val1, @equation, @val2)
This would be

.calc(width, 100%, "+", 10px);

Its best to just use the mixin, but if you need to write a longer equation for some reason and calculate many fields, then the mixin wont work. For example, if you want to calculate the body height minus the header and footer

height: calc((100%) - @{headerHeight} - @{footerHeight});

Needless to say, if you arnt using a bundler, the no need to worry... carry on as you were!

Create a panel

The white boxes are called 'panels' in the case of this project. The main use is to hold the content segment.

Each segment will be a 'DIV' with a class of "panel__block"

<div class="panel__block">
    <h2 class="panel__title">TITLE</h2>

    <div class="panel__content">
        <!--panel content goes here-->
    </div>

</div>

If the panel__block DOM element is beside a sidebar block, it will automatically fit to the remaining width beside the sidebar.

<section class="main__content">
    <div class="sidebar__wrapper">
        <h2 class="sidebar__title">OPTIONS</h2>

        <!--sidebar content goes here-->

    </div>

    <div class="panel__block">
        <h2 class="panel__title">TITLE</h2>

        <div class="panel__content">
            <!--panel content goes here-->
        </div>

    </div>

</section>

Create an icon

<i class="icon"></i>