Portfolio

Carl James Trelfa

The Design

Every good web-site starts with an idea, but we're not here for web site ideas so we'll start with a design!

The actual design side of web sites isn't my strong point, implementation of designs is my thing.  I did my initial design for this site on paper and worked from there, with the design kind of evolving.  It's not my ideal method of designing a web site, much better to work with a proper designer. Some parts, such as the rounded borders and drop shadows were used purely for the sake of using some obvious CSS3 features.

It doesn't matter to me what format the initial design comes in, PSD, PDF, HTML/CSS or even Flash, as long as I can extract the images, colours, fonts and figure out the layout, I can turn it in to an efficiently crafted end result.

The next step after the design is received is to make a template file or two.  Essentially convert the design in to HTML/CSS on a static .html page.  Once the HTML version of the design is finalised, I can seperate out chunks of re-used HTML in to their own files and use PHP to output the final, dynamic pages.  More on that in the PHP Section of the site.

CSS3

CSS is used to separate the actual design styling of the site from the content.  The idea is to keep the two completely separated so my resulting HTML is compact, easy to work with and easily deciphered by search engines.  All pages use a common CSS file so page load times are faster as the style data is cached and doesn't need to be downloaded for every page.

CSS3 standards have been referenced and ahered to during the development of this site and validated at:

https://jigsaw.w3.org/css-validator/

I've used some CSS3 features, such as the rounded borders and drop shadows.  I probably wouldn't use them the way I have here for a "proper" site - they are predominantly used as they are easily recognisable CSS3 features.

SASS

I used SASS to make the CSS easier to manage.  For example, I'm using MIXINS and VARIABLES so I don't have to repeat values and properties and if I need to change them, I only need to edit a single line in a single file to affect the whole CSS (no searching and replacing in the final CSS file).

I've used SCSS syntax thoughout as the PHP SASS compiler only supports that syntax.

SASS Mixins & Vars

$mainColour: #003399;
$mainColourLight: #9BCDFF;
$accentColour: #993300;
$accentColourLight: #FFE084;
$outerBorderRadius: 10px;
$innerBorderRadius: 8px;

@mixin border-styling {
    border-style: solid;
    border-color: $mainColour;
}

@mixin box-shadow {
    box-shadow: 2px 2px 5px grey;
}

There are more MIXINS and VARIABLES used, this is just an example.

So if I want to recolour the site, I just change the colour variables and the CSS is automatically re-processed with the new style data.

I can also change the shadow and border styling throughout by simply editing the relevant MIXINS.

The variables and MIXINS are stored in a seperate file to the main CSS data for the site, meaning I can re-use them if I need CSS for different mediums (eg. mobile).

SASSY Codeblock CSS

.codeBlockHolder {
    background: $mainColour;
    background-image: url("../img/codeblockbg.png");
    margin-left: 100px;
    margin-right: 200px;
    border-top-right-radius: $outerBorderRadius;
    @include box-shadow;
}

.codeBlockHeader {
    background: $accentColourLight;
    color: $accentColour;
    margin-bottom: 20px;
    width: 30%;
    padding-left: 5px;
    p {
        font-weight: bold;
        margin-top: 0px;
    }
    border-bottom-right-radius: $innerBorderRadius;
    @include border-styling;
    border-width: 2px 0px 0px 2px;
}

.codeHolder {
    color: $mainColourLight;
    font-family: "courier";
    padding-left: 25px;
    padding-right: 25px;
    padding-bottom: 20px;
    white-space: nowrap;
    text-overflow: clip;
    overflow-x: auto;
}

The SASSY CSS above is used the for the code boxes used throught the site. 

As you can see I've used those Variables for the rounded borders and colours and those Mixins for the drop shadow and the border styling.  Some styles, such as the style of the P tag in the code block header use nested styles which are great for helping coders better understand and edit the style sheet (actually I probably could achieve the same result without the nested style, but I wanted to demonstrate it in this example).

Also note the image that is used as a background.  It's url is specified relative to the style sheet, not the page - this means the server will always be able to find it without worrying exactly where the HTML page resides in the file system.

And here is the CSS all that SASS code compiles to:

Compiled CSS

.codeBlockHolder {
  background: #039;
  background-image: url("../img/codeblockbg.png");
  margin-left: 100px;
  margin-right: 220px;
  border-top-right-radius: 10px;
  box-shadow: 2px 2px 5px grey; }

.codeBlockHeader {
  background: #ffe084;
  color: #930;
  margin-bottom: 20px;
  width: 30%;
  padding-left: 5px;
  border-bottom-right-radius: 8px;
  border-style: solid;
  border-color: #039;
  border-width: 2px 0px 0px 2px; }
  .codeBlockHeader p {
    font-weight: bold;
    margin-top: 0px; }

.codeHolder {
  color: #9bcdff;
  font-family: "Courier New", Courier, monospace;
  padding-left: 25px;
  padding-right: 25px;
  padding-bottom: 20px;
  white-space: nowrap;
  text-overflow: clip;
  overflow-x: auto; }

It's more much efficient to edit your CSS using SASS!

Here's how the code block displays are represented in HTML (this example is the example code block from the homepage):

Codeblock HTML

<div class="codeBlockHolder">
    <div class="codeBlockHeader">
        <p>Some Example Code</p>
    </div>
    <div class="codeHolder">
        <p>Some code Some code Some code<br/>
        Some code Some code Some code<br/>
        Some code Some code Some code</p>
    </div>
</div>

Nice, compact HTML with no un-necessary in-line styling - it's easy to understand and work with.

Fonts

I've used three web-safe fonts on this site, Verdana for most of the text, Arial for the navigation and Courier New for the code blocks.  I set the default size to 16px so browser settings don't mess up my layout and use em units for the other sizes (as recommended by W3C).

Fonts CSS

body {
    font-family: Verdana, Geneva, sans-serif;
    font-size: 16px;

    // there's a bit more css for other stuff here

}

    // css for nav font
    font-family: Arial, Helvetica, sans-serif;

    // css for code block font
    font-family: "Courier New", Courier, monospace;

If you wanted to do something more interesting with fonts you could use these Google Fonts or Web Kit.  Google's fonts are nice and easy to use and also free, which is always an advantage!

Home > Technical Skills > CSS