Posts Tagged ‘class 4’

Class 4 – Quiz Warning!

Wednesday, March 3rd, 2010

We will be having a quick quiz on Saturday that reviews the basic concepts we have covered in class so far.  Anything from the readings or assignments from Class 1 to Class 3 is fair game, so make sure you are up to date.  Topics covered include (but are not limited to), basic HTML syntax and common elements covered in class, CSS syntax, CSS selectors, information architecture navigation concepts, Javascript’s relationship to Java, the relationship between client and server.

There will also be questions about file management.  Please refer to this post for guidelines on file management for class projects:
http://wd.onepotcooking.com/2009/07/15/class-1-managing-project-files

So make sure you understand how you are supposed to structure your files for projects in class, how your file and folder structures on the server that you create with WinSCP correspond to the addresses you type into the web browser, and the difference between relative and absolute paths.  This site has a decent description of absolute and relative paths that is a good recap of what we discussed in class: http://www.communitymx.com/content/article.cfm?cid=230ad

The quiz will *not* cover using CSS for layout with the float and clear properties.

Class 4 – Assignment #2

Saturday, October 10th, 2009

For those of you who have completed assignment #1, your next assignment is to go through the same process with this new design comp:

app_screenshot

The image files necessary for this assignment are, as with the previous one, available on the server here.

The global navigation buttons (i.e. “Home”, “Friends’ Videos”, “Featured Videos”) should be done using an unordered list <ul> element, as recommended in the previous assignment.

The only font used on this page is Tahoma.

  • The light blue font color has hexadecimal code, #AEBEE1
  • The dark blue font color is #3B5998
  • The dark gray font color used for the regular text on the page is #333333
  • The light gray font color used for dates is #999999

Some of the background colors used are #F7F7F7 and #D8DFEA.

The light gray borders used between listings in the “Recent Activity” area is #DDDDDD.

The “+” and heart buttons that show up to the right of each video in the “Recent Activity” section should use the sprite rollover technique we discussed in Class 3.  The example of the sprite technique is available here.



Class 4 – Assignment #1

Saturday, October 10th, 2009

The first assignment for this week is to convert the following design comp into valid XHTML and CSS code.  All the necessary images have been pre-cut by your thoroughly competent in-house graphic designer, and are available in the images sub-folder on the server.

app_screenshot

Fonts

The fonts used on the page are Georgia for the serif font, and Arial for the sans-serif font.

Tips

To begin converting any design comp into XHTML and CSS code, I would recommend setting up a basic page with the design comp applied as a background image to the container div, following the background image technique outlined elsewhere.

Then, start thinking about how you would create an outline structure with the proper rows and columns. This usually means thinking in terms of the container div and second-level divs that you can create to generate the basic sections of the page without worrying about the content that goes into each section yet.

If the design comp shows columns of content that sit side-by-side, you may want to look into using the clear/float layout technique, if necessary, which is how you coerce block elements, such as divs, to sit side-by-side.

Avoid using the CSS position or z-index properties.  It is usually not necessary, and is often a source of trouble for inexperienced developers.  Usually, you can position elements properly through a combination of margin and padding, and the float and clear trick.

For this comp, I would start with an outline of the page in the <body> of an XHTML document, something like the following:

<div id="container">
    <div id="main_navigation">
    </div>
    <div id="search_bar">
    </div>
    <div id="search_results">
    </div>
    <div id="footer">
    </div>
</div>

This simple XHTML code has all the major sections of the page broken up into divs.  Now your job is to use CSS to put them into their appropriate positions and sizes.

Once you have the basic layout of the sections done, you can move on to more specifics, and start to think about how some of the parts of the content would be coded in the XHTML.

Global navigation

The global navigation looks like this:

app_screenshot_r2_c4

This is not so different from the global navigation menu example we looked at in class, where we converted an unordered list of elements into a horizontal set of links.

So you might want to do something similar for this assignment.  For example, working off of that example, you might want to set up the XHTML code for this global navigation to be something similar to this:

<div id="global_nav">
   <ul>
       <li class="selected"><a href="#">Recently Opened</a></li>
       <li><a href="#">My Ratings</a></li>
       <li><a href="#">My Friends</a></li>
       <div class="clear"><div>
   </ul>
</div>

Of course, you’ll then have to work on the CSS.  For this example, you will want to use background-images behind each of the list items to give it the red or black background.

Sort options

The sort options allow the user to order the listings shown on the page in a variety of ways.

app_screenshot_r6_c5

You will want to be able to apply the proper colors and styles to the links inside of this section, as well as make the “Recently Opened” link look “active”, i.e. bold.

So you would structure your XHTML in such a way that the whole section is contained within its own <div> tag, and the links are within <a> tags.  The “active” link simply has an “active” class applied to it, which allows you to add special styles to that link in the CSS.

<div id="options">
   Sort Listings by
   <a href="#">Venue Name</a>,
   <a href="#">Top Rated</a>,
   <a href="#" class="active">Recently Opened</a>
</div>

As with the selected element in the global navigation section, we can use a special CSS selector to make the link with class “active” look bolder than the other ones.

Listings

The listings of venues should be a table with one row for each listing.  Each row is divided up into several table data cells.

app_screenshot_r8_c2

As you can see, each table data cell has a few pieces of content.

Here is an example to give you an idea of how you might code the XHTML for one such row.  You do not necessarily have to do your rows exactly like this, but it should at least give you a starting reference point:

<tr >
	<td class="namecell">
		<div class="name">
                    <a href="#" >Travertine</a>
                </div>
		<div class="location">
                    <a href="#" >Nolita</a>
                </div>
	</td>
	<td class="typecell">
		<div class="type">
			<a href="#" >Restaurant</a>
		</div>
		<div class="subtype">
			<a href="#" >Mediterranean</a>
		</div>
	</td>
	<td class="goingcell">
		<div class="going">
			<div class="checkbox_container">
				<input name="going" type="checkbox" class="going_checkbox" >
			</div>
			<label class="going_here">I'm going here</label>
			<div class="clear"></div>
		</div>
	</td>
	<td class="ratingcell">
		<div class="user_rating">
			BB User Rating: 0
		</div>
		<div class="ratebox">
			<a href="#" >Click here to rate!</a>
		</div>
	</td>
</tr>

Pagination

The pagination section towards the bottom of the page is conceptually a list of page numbers.

app_screenshot_r10_c6

And you know that a list should probably be created in code using the <ul> or <ol> tags, as we saw with the global navigation.

Here is an example set of code that could potentially be used to create this pagination section:

<div class="pagination">
	<ul>
		<li class="current"><a href="#">1</a></li>
		<li><a href="#">2</a></li>
		<li><a href="#">3</a></li>
		<li><a href="#">4</a></li>
		<li><a href="#">5</a></li>
		<li><a href="#">6</a></li>
		<li><a href="#">7</a></li>
		<li><a href="#">8</a></li>
		<li><a href="#">9</a></li>
		<li><a href="#">10</a></li>
		<li><a href="#">Next</a></li>
		<li><a href="#">Last</a></li>
	</ul>
</div>

The list item with the class=”current” could be styled differently so that it appears to be “selected with an overline or top border.

Styling the submit button

The submit button in the BlackBook design comp may be a bit confusing.  Here is a tip on how to get your button to look exactly right.

Picture 1

The HTML code is just that for a simple submit button:

<input type="submit" class="blackbooksubmit" value="Submit">

And the corresponding CSS code is:

input.blackbooksubmit {
 background-color:#A30606;
 border:0 none #FFFFFF;
 color:white;
 font-family: Arial,Helvetica,sans-serif;
 cursor:pointer;
 font-size: 11pt;
 font-weight:bold;
 padding:4px 10px 5px;
 text-align:center;
 width:69px;
}

Class 4 – Formula for Calculating Widths of Columns in Layout

Tuesday, July 14th, 2009

When working on the layout of a web page, it helps to have a formula for calculating the width setting you should apply to boxes inside of the container div.  This formula takes into account all padding and margins that might have an effect on the dimensions.  Here is the formula:

width of inner boxes = width of container
 - left padding of container
 - right padding of container  
 - (number of inner boxes * left margin of inner boxes)
 - (number of inner boxes * right margin of inner boxes)
 - (2 * number of inner boxes * border width on inner boxes)

Class 4 – MTV Example Layout

Saturday, March 7th, 2009

Here is the example code for the general high-level layout of the MTV Layout Assignment.   This example was meant to show you the general approach you should take when trying to convert a design comp into XHTML and CSS.  I’ve shown how to lay out the main parts of the page using the basic float and clear technique, but haven’t gone into detail of how to then subdivide those parts.  You can view a live version of this example code here.

The XHTML file, index.html:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>MTV Assignment Layout</title>
	<link type="text/css" rel="stylesheet" href="styles/mtv_layout.css" />
  </head>
  <body>
	<div id="container">

		<div id="header_box">Header</div>
		<div id="topnav_box">Top Nav Buttons</div>
		<div id="left_box">Left Box</div>
		<div id="right_box">Right Box</div>
		<div class="clear"></div>

	</div>
  </body>

</html>

And here is the CSS file, styles/mtv_layout.css:

div#container {
	background-image: url(../images/mtv_screenshot.png);
	width: 760px;
	height: 1000px;
}
div.clear {
	clear: both;
}
div#header_box {
	height: 72px;
	background-color: yellow;
	opacity: 0.5;
}
div#topnav_box {
	height: 32px;
	background-color: blue;
	opacity: 0.5;
}
div#left_box  {
	float: left;
	margin-top: 10px;
	width: 448px;
	height: 800px;
	background-color: pink;
	opacity: 0.5;
}
div#right_box {
	float: left;
	margin-left: 10px;
	margin-top: 10px;
	width: 302px;
	height: 800px;
	background-color: orange;
	opacity: 0.5;
}

Class 4 – Background Images & Positions

Saturday, March 7th, 2009

This example shows you how to use a background image as an icon, similar to some of the icons that were displayed in the MTV Music Video Facebook App design comp.

Click here to view this code in your browser.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>Aligning Background Image</title>
	<style type="text/css">
div#menu_item1 {
	width: 150px;
	height: 20px;
	line-height: 20px;
	background-image: url(images/button_playlist.gif);
	background-repeat: no-repeat;
	float: left;
}
div#menu_item2 {
	width: 150px;
	height: 20px;
	line-height: 20px;
	background-image: url(images/button_favorite.gif);
	background-repeat: no-repeat;
	float: left;
}
div#menu_item1:hover, div#menu_item2:hover {
	background-position: 0px -46px;
}
a.menu_link {
	display: block;
	width: 23px;
	height: 20px;
	float: left;
	margin-right: 5px;
	outline: 0px;
}
	</style>
  </head>
  <body>
	<div id="menu_item1">
		<a href="#" class="menu_link"></a>
		<span>Add to Playlist</span>
	</div>
	<div id="menu_item2">
		<a href="#" class="menu_link"></a>
		<span>Add to Favorites</span>
	</div>
  </body>

</html>

Class 4 – CSS Positioning

Saturday, February 28th, 2009

The CSS “position” property has three possible values: “static”, “relative”, and “absolute”.

Static is the default value used by the browser if none other is specified in the CSS.  Statically positioned elements are often referred to as “unpositioned” since no special positioning has been applied to them.  Here is an example of a simple page with two boxes, with no special positioning applied:

Example of static positioning

Example of static positioning

Relative positioning is used to shift any elements position relative to where it would normally be if it had the default static positioning.  If, for example, we wanted to shift an element over 10 pixels to the right from where it would normally sit on the page, we could give it relative positioning and set the “left” CSS property to be 10px or so.  This would shift it 10 pixels to the right.

Here is an example of an element with relative positioning.  You can see that the yellow box is shifted a few pixels up higher on the page than where it would normally sit.

Example of relative positioning

Example of relative positioning

Absolute positioning allows us to set any element’s position relative to the absolute top-left corner of the browser window.  So if you always wanted an element to sit 20 pixels down, and 30 pixels to the right of the top-left of the browser window, we could give it absolute positioning, and set its “top” property to be “20px”, and its “left” property to “30px”.  This would shift it that exact position relative to the top left of the browser window.

Here is an example of an element with absolute positioning.  Notice that if you resize the window, the red box (the parent element) stays in the center, but the yellow box (the child element) never moves out of position.  Its position is always fixed relative to the top-left of the browser window.

Example of absolute positioning

Example of absolute positioning

There is one important special case in which absolute positioning is not relative to the top-left of the browser window.  This is when the absolutely positioned element is a child of another positioned parent element.  The parent element can be either absolutely or relatively positioned… it doesn’t matter so long as it has its position set to something other than “static”.  In these cases, the absolutely positioned child element will be positioned relative to the top-left corner of its parent element, not the browser window.

Here is an example of an absolutely positioned child element within a relatively positioned parent element.

Example of an absolutely positioned element within a relatively positioned element

Example of an absolutely positioned element within a relatively positioned element

For each of these examples, the basic XHTML structure of the page is identical.  It is only the CSS position properties (“position”, “top”, and “left”) which make these pages behave differently.

Class 4 – CSS & Javascript Workaround for IE6

Saturday, February 28th, 2009

This code can be put in the <head> element of your page, and will only be interpreted by the IE6 browser.  So you can use it to load special stylesheets or javascripts that will override the other styles or scripts you have set.

<!--[if lte IE 6]>
<link href="/css/ie_hacks.css" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/frontend/iepngfix_tilebg.js"></script>
<![endif]-->

To see more information about these “conditional comments”, check out this page on the quirksmode.org website.