Difference between revisions of "Courses/single-page-portfolio"

From Publication Station
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
For this course, we're going to build a very basic website that looks a little like [http://arrivabusandcoach.co.uk/buses-the-weird-and-wonderful?utm_source=onepagelove&utm_medium=outreach&utm_campaign=april this].
For this course, we're going to build a very basic website that looks a little like these: [http://arrivabusandcoach.co.uk/buses-the-weird-and-wonderful?utm_source=onepagelove&utm_medium=outreach&utm_campaign=april 1],[http://epic.net/newsletters/2015-epic/ 2],[http://melaniedaveid.com/].


== Getting a headstart ==
== Getting a headstart ==
Line 6: Line 6:


== Preparing your folder and our files ==
== Preparing your folder and our files ==
The first thing you have to understand is that everything that we'll be writing is basically plain text. This means that your entire website basically consists of text files that are written in a specific way. You could even use a very basic text editor like textedit or notepad. However, programs that are specifically made for writing code often have handy features. Therefore, it's better to use a program like textwranglet, that gives you a few handy code editing features.   
The first thing you have to understand is that everything that we'll be writing is basically plain text. This means that your entire website basically consists of text files that are written in a specific way. You could even use a very basic text editor like textedit or notepad. However, programs that are specifically made for writing code often have handy features. Therefore, it's better to use a program like Sublime Text, that gives you a few handy code editing features.   


First, you should '''create a folder''' in which you'll be keeping all of your files. Call it whatever you like. After this, you open TextWrangler. '''Write''' anything you like and then '''save it as index.html''' in the folder you just created. Now find this file in finder and '''open it with a browser''', preferable Chrome. You just created a website! But to give it structure and make it look good, we'll need to write some html. Erase your previous text and proceed with the next step: creating the basic html structure.
First, you should '''create a folder''' in which you'll be keeping all of your files. Call it whatever you like. After this, you open Sublime Text. '''Write''' anything you like and then '''save it as index.html''' in the folder you just created. Now find this file in finder and '''open it with a browser''', preferable Chrome. You just created a website! But to give it structure and make it look good, we'll need to write some html. Erase your previous text and proceed with the next step: creating the basic html structure.


=== Doctype, html, head and body ===
=== Doctype, html, head and body ===
Open your index.html again in TextWrangler. Start by declaring the doctype on the first line. This tells the browser that the document will be written in HTML. After this, it's always smart to immediately write all the necessary tags you always need for an HTML document. This includes the html tag, but also the head and the body. In the head you will include information for the browser, like the document title and links to stylesheets and javascript files. In the body you place the html that people will really see.
Open your index.html again in Sublime Text. Start by declaring the doctype on the first line. This tells the browser that the document will be written in HTML. After this, it's always smart to immediately write all the necessary tags you always need for an HTML document. This includes the html tag, but also the head and the body. In the head you will include information for the browser, like the document title and links to stylesheets and javascript files. In the body you place the html that people will really see.


<source lang="html5">
<source lang="html5">

Latest revision as of 11:38, 1 September 2015

For this course, we're going to build a very basic website that looks a little like these: 1,2,[1].

Getting a headstart

To get a headstart and leave everybody in the dust, follow the HTML & CSS courses on Codecademy [2] first.

Preparing your folder and our files

The first thing you have to understand is that everything that we'll be writing is basically plain text. This means that your entire website basically consists of text files that are written in a specific way. You could even use a very basic text editor like textedit or notepad. However, programs that are specifically made for writing code often have handy features. Therefore, it's better to use a program like Sublime Text, that gives you a few handy code editing features.

First, you should create a folder in which you'll be keeping all of your files. Call it whatever you like. After this, you open Sublime Text. Write anything you like and then save it as index.html in the folder you just created. Now find this file in finder and open it with a browser, preferable Chrome. You just created a website! But to give it structure and make it look good, we'll need to write some html. Erase your previous text and proceed with the next step: creating the basic html structure.

Doctype, html, head and body

Open your index.html again in Sublime Text. Start by declaring the doctype on the first line. This tells the browser that the document will be written in HTML. After this, it's always smart to immediately write all the necessary tags you always need for an HTML document. This includes the html tag, but also the head and the body. In the head you will include information for the browser, like the document title and links to stylesheets and javascript files. In the body you place the html that people will really see.

<!DOCTYPE html>
<html>

  <head>
    <title>My title</title>
  </head>

  <body>
    My content
  </body>

</html>


Adding a CSS file

Now we want to style our content. To do this, we first have to add a link to a stylesheet in the head of index.html like so:

  <head>
    <title>My title</title>
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>

You can see that we are linking to "style.css", so this is the file we will have to create. Open a new file in TextWrangler and add the following text:

  body{
    background: red;
  }

This makes the background of our site red, just to see if it works. Save this file as "style.css" and save it in your folder. If you open index.html in your browser again, you should see that the background is now red.


Adding your content

Adding the sections

Your page will consist of several sections, so let's start by adding three of these to your body. Because we want to give them all a different background, we need a way to identify them. To do this, we'll be giving them classes. To test, we'll also be adding a little content to the sections.

<section class="section1">these</section>
<section class="section2">are</section>
<section class="section3">sections</section>

Styling the sections

Open your CSS file in TextWrangler and delete the contents. First we are going to give all sections a relative position. This means that they will be placed in their natural order in the document. We're also giving them a width and height of 100%, so that they fill the screen.

section{
  position:relative;
  height: 100%;
  width:100%;		
}

Als je dit opslaat en je browser ververst, zie je dat dit helaas nog niet werkt. Dit komt door een rare kronkel in html, niemand weet waarom. Gelukkig kun je het makkelijk wel laten werken, namelijk door er deze code boven te plaatsen:

body, html {
  height: 100%;
}

Erg boeiend is dit nog niet, dus laten we de sections allemaal een eigen kleurtje geven. Weet je nog dat we de sections allemaal een class hebben gegeven? Die gaan we nu gebruiken!

section.section1{
	background:red;
}

section.section2{
	background:green;
}

section.section3{
	background:blue;
}

Adding text and images

Now that the sections are ready, we can fill them with some content. To add an image, you first have to find one. Find a random image on the internet and save it to the folder you are working in. After this we place the text. To keep everything together, we'll put all the text in a div with a class. A div is basically an invisible box that you can use to keep elements together. In this div we'll place a header and two paragraphs. Now we wrap the whole thing in another div with a class, you can use this later to place it in the center. You place this code inside your first section:

<div class="center">
  <img src="bestandsnaam.jpg">
  <div class="description">
    <h3>This is a header!</h3>
    <p>This is a paragraph with some text.</p>
    <p>This is another paragraph with some text.</p>
  </div>
</div>

Of course you replace "bestandsnaam.jpg" with the name and extension of the file that you just saved to your folder. Refresh your browser to check if it works.

Placing the text and images

First we give the outer div a width of 800 pixels and place it in the center of the screen using "margin:auto 0;", which somehow works. We give the image and the text div a width of 48% and an absolute position. This already places both elements in the top left corner of the .center, so now we place the image on the right side.

.center{
	width:800px;
	margin:0 auto;
}
.center .description, .center img{
	position:absolute;
	top:0;
	width:48%;
}
.center img{
	left:50%;
}

Etcetera

- fixed menu - background image - transform on hover - multiple absolutely positioned images