--- post_visible: true status: published title: YSDN Interactivity Workshop – Week 2 subtitle: Continuing to learn some web basics for building things like portfolios. slug: 2013-02-28-ysdn-interactivity-workshop-week-2 date: '2013-02-28' author: Nate Butler primary_tag: education tags: - education - dev summary: >- Welcome to the YSDN Interactivity Workshop. Here we will learn how to build a simple website using Bootstrap, and learn some important basics about web development. Hopefully you are excited to get learning, so lets get to it! featured: true --- Welcome back everyone! This week we are going be covering interaction, and learning how to work with jQuery and CSS animations. We'll also be adding a page or two to the site we made in the last workshop. Having attended the previous workshop is recommended, but not required. I will try to write this week's content with zero assumptions, but it might be a good to read through the [week one](https://github.com/iamnbutler/YSDN-Interactivity-Workshop/wiki/Week-1) wiki page. ## Before Starting Download this week's Resources * [Resources Zip](http://www.mediafire.com/download.php?wd24iiutgsc5b72) * [Complete Site Zip](http://www.mediafire.com/download.php?btvbmrjd447k0zz) Final Product for this Week http://iamnbutler.com/demo/ysdn/workshop-1/week-2/ ## Workshop ### Getting Started All right, here we go! Let's start by grabbing the resources we need for this week. [Grab them here](http://www.mediafire.com/download.php?wd24iiutgsc5b72) Also, if you need some help, or are working on this outside of the workshop, for your benefit I've included a complete version of what we will finish this week for you to dissect, or check your own code against. [Grab it here](http://www.mediafire.com/download.php?btvbmrjd447k0zz) Make a new folder and extract `ysdn_workshop_week_2_resources.zip` directly inside of it. You should see the following files/folders in that folder: * `css` * `bootstrap.min.css` - *This holds the main Bootstrap CSS* * `bootstrap-responsive.min.css` - *This holds the CSS that makes Bootstrap responsive* * `style.css` - *This is our custom CSS* * `img` * (Images) * `js` * `bootstrap.min.js` - *This holds all of Bootstrap's custom scripts* * `index.html` *** ### What is Responsive Web Design? Before we start, let's make sure everyone is one the same page here. What does it mean when we say "make some (site) responsive"? Well here is a fun example by [Masayuki Kido](http://roxik.com/), a web developer/interaction designer to help illustrate: [Responsive Cat](http://roxik.com/cat/) Another example from the A List Apart responsive web design (RWD) article: [Smashing RWD Example](http://alistapart.com/d/responsive-web-design/ex/ex-site-flexible.html) Essentially, Responsive Web Design is an effort to make web pages *respond* better to the current size of the browser. This can range from changing the size of images to entirely new layouts based on width and height of the current window. Since we are using Bootstrap we have access to its responsive style sheet, which will deal with most of this automagically. If you are interested in learning more about RWD, I've included some links in the Additional Resources section at the bottom of this page. ### Making Our Site Responsive Now enough about RWD itself, let's get our site running responsive. Open up your `index.html` file in your text editor of choice and find line 17: ```html ``` We are going to remove the html comment block (``) ```html ``` Now open up `index.html` in the browser if you do not have it open already. (Make sure to refresh the page if you already had it open!) Now try re-sizing the width of your browser. Try making it wider, and try making in narrower. How exactly does this work? Well in the time we have it would be difficult to go through it all, but to put it simply, bootstrap's `.span` classes and its structure take care of the layout when we re size it. Elements of a certain `.span` width eventually become one column at what is known as a "break point." *** ### Getting Started with jQuery Let's learn some jQuery! jQuery (or jQ for here on out) is not a language of its own, but a 'framework' built on top of Javascript (JS.) We won't be touching any pure Javascript in this workshop, but just be aware that they are not the same thing! Navigate to the `scripts` folder and find `scripts.js`. We are going to open that up in our text editor. You should see a section like this: ```javascript $(document).ready(function() { // jQuery goes inside here! // This makes it so that our scripts don't load before the page is ready }); ``` This is called the "document ready" block. What it does is it makes sure that our scripts don't load before the elements on the page load. Say I want to run a script on one of the images we have on our page. If I try to `show()` that element, or `hide()` it but it has not yet loaded, the command will simply do nothing. To prevent this behavior we put 99% of our jQ code inside the "document ready" block. You can copy + paste this block from project to project, but eventually typing it out will become natural. ### Making Elements Fade In Let's make the sections of our simple site fade in using the handy jQ function `fadeIn()`. Before we get started, the jQuery documentation is one of the best places you can go when you get stuck on a jQuery problem. You can check it out [here](http://api.jquery.com/). Before we get into the jQ magic to make this work we need to make some changes to our `html` and `css` files. `index.html` (first line is the original, second is the new line) Line 44 ```html