Making Pickup Soccer Flexible - Exercise

Contact Us or call 1-877-932-8228
Making Pickup Soccer Flexible - Exercise

Making Pickup Soccer Flexible

Duration: 20 to 30 minutes.

Let's apply the same process to the Pickup Soccer page that we did to the Jazz Calendar page: we'll change a fixed-width design into a more flexible, percentage-based design. Keep in mind the key rule here: percentage widths are calculated by dividing the pixel width of the element by the pixel width of its containing element.

  1. Open FlexibleGrids/Exercises/pickupsoccerflexible/css/style.css in your file editor.
  2. Using the fixed-width page from exercise 1 as a starting point, find percentage widths for each element. The markup won't change - just the CSS.
  3. Be sure to update margins and padding for each element, so that things line up regardless of the size of the browser window.
  4. View FlexibleGrids/Exercises/pickupsoccerflexible/index.html in your browser to check your work. Don't forget to resize your browser window (horizontally), to make sure that things work correctly!

Solution:

FlexibleGrids/Solutions/pickupsoccerflexible/css/style.css
body {
	font-family:Georgia,serif;
	background-image:url('../images/bg_grass.jpg');
}

a {
	text-decoration:none;
	color:#4040AD;
}

a:hover {
	text-decoration:underline;
}

#container {
	width:85%;
	margin:0 auto;
	background:#fff;
}

header {
	background-color:#d0b462;
}

header #logo {
	margin:1.0416666% 0 1.0416666% 3.75%;
}

nav {
	padding:1.0416666% 3.75% 1.0416666% 3.75%;
	float:right;
}

nav ul {
	display:inline;
}

nav ul li {
	display:inline;
}

nav ul li a {
	color:#fff;
	text-decoration:none;
	margin-left:20px;
}

#maincontent {
	width:61.7708333333%;
	padding:1.0416666% 0 3.75% 3.75%;
	float:left;
}

#maincontent h1 {
	font-size:36px;
	margin:5px 0 20px 0;
}

#maincontent .game {
	float:left;
	width:47.892074199%;
	line-height:14px;
	font-size:14px;
	margin:0.8431703204%;
}

#maincontent .game img {
	float:left;
	margin:0 2.86% 0 0;
}


#sidebar {
	width:26.9791666667%;
	float:right;
	padding:3.75%;
	color:#333;
	line-height:20px;
}

#sidebar h3 {
	font-style:italic;
	font-size:20px;
	margin:0 0 5px 0;
}

#footerinfo {
	clear: both;
	background-color:#151570;
	padding:1.0416666% 0 1.0416666% 3.75%;
}
#footerinfo p {
	color:#fff;
}

The left (#maincontent) column gets a width of 593/960, or 61.7708333333%. Similarly, the right (#sidebar) column gets a width of 259/960, or 26.9791666667%. Paddings and margins get a corresponding percentage width.

Next