Professional Documents
Culture Documents
design studio
In print design, laying out a page or a spread means bringing in imagery, wrapping text, creating columns, making gutter, and defining spaces with graphic treatments like borders. Web design is the same except instead of using a page layout program like InDesign, we use CSS to push HTML tags around. Wrapping Text with Floats If you want an image to have text wrapping, you can use CSS to float it to the left or right. Simply telling an image to float: left; or float: right; will do the trick. Also, youll want to make sure theres some margin around the sides of the image the text might bump against. For an image that is floated to the left, that means adding margin to the right side (and potentially the top and bottom.) For an image that is floated to the right, that means adding margin to the left side. Image floated right, margin on the left
Heres the HTML: <img class="headshot" src="images/tron-guy. jpg" alt="Tron Guy"> <p> Tron Guy A husky, 48-year-old computer consultant, Jay Maynard, designed a Tron costume, complete with skin-tight spandex and light-up plastic armor, in 2003 for Penguicon 1.0 in Detroit, Michigan. The Internet phenomenon began when an article was posted to Slashdot, followed by Fark, including images of this costume. </p> Heres the CSS: img{ float: right; margin-left: 10px; margin-bottom: 10px; }
Visual Tech
design studio
When we float children tags, the parent tag colapses on itself. Dont ask why it just does.
Visual Tech
design studio
Notice that step 2 caused something odd to happen. The parent container <div class=wrap> is not surrounding the nested boxes anymore it collapsed on itself. Here is how you will fix this. 3. Clear your floats. The simplest meathod that works most of the time is to set the overflow property of the parent element to hidden like this. .wrap{ width: 960px; overflow: hidden; } .main{ width: 760px; float: left; } .side{ width: 200px; float: right; } Once we clear the float, the parent tag encapsulates its children again. There are many ways to clear floats, this is just one technique. Check out these links for more. http://css-tricks.com/all-about-floats/ http://perishablepress.com/press/2009/12/06/new-clearfix-hack/ http://www.w3.org/wiki/Floats_and_clearing http://www.cssforums.org/
<div class="wrap"> <div class="main"> </div> <div = class"side"> </div> <div>
Visual Tech
design studio
760 px
200 px
960 px
But add any amount of width to either of the interior columns with a border, padding, or margin property, and your layout will break because the total width of the interior coulumns is greater than the parent. If you add a 10-pixel border to the sidebar, the total width of the sidebar becomes 210 pixels, and 970 total pixels wil not fit in to a 960 pixel parent box.
960 px
When a floated object doesnt have room to float up next to another object, it just drops down to the next line. Takeaways: Keep it simple. Were designers not mathematicians. If something seems to be pushed down below where it belongs, check the combined width by adding up the width declared for your object, as well as the width added by the border, padding, or margin on the left and right sides of your tag. Odds are you have tried to squish too much into too small a space. width: 500px; width: 500px; border: 10px;
760 px
210 px
Visual Tech
design studio
setting borders
We set borders for a tag using the border property. nav{ border: 5px solid #000; } This CSS will set a solid border of five pixels on all four sides of the <nav> tag.
If you prefer more control over your borders than setting the border to be the same on all sides, you also have the following properties, starting clockwise from the top: border-top, border-right, border-bottom, and border-left. If you leave one of these out, your element wont have a border on it at all. So if you want a thick dark line at the bottom of your navigation and a thin grey one at the top of your navigation but nothing on the sides, you might write your CSS like this: nav{ border-bottom: 5px solid #000; border-top: 1px solid #DDD; }
1.border-top
4.border-left
2.border-right
3.border-bottom
Notice that were putting three separate values in the value are of the CSS rule: The first is the thickness or width of the border (5px, 1px). The second is the style of border (solid). The third is the color (#000, #DDD). Youll want to keep those values in order and separate each with a single space, keeping them all on the same line Setting the Style of Borders If instead of s solid border, you wanted a dotted border, a dashed border, or a double border, you can create that as well. nav{ border-bottom: 5px solid #000; border-top: 1px dotted #DDD; }
Visual Tech
design studio
adding padding
We use the padding property to add space that butts up against the border on the inside of a tag. As with the border property, you can set the padding for all four sides of a tag like this: nav{ border-bottom: 5px solid #000; border-top: 1px dotted #DDD; padding: 20px; } Or you can set a different padding for each of the four sides with the following properties (notice that they work just like the border properties, clockwise starting with the top): padding-top, padding-right, padding-bottom, and padding-left. nav{ border-bottom: 5px solid #000; border-top: 1px dotted #DDD; padding-top: 20px; padding-bottom: 15px; }
1.border-top
4.border-left
2.border-right
3.border-bottom
Since the padding is on the inside of the border, if you set a background color for the tag, it will fill in behind the padding all the way up against the border. nav{ border-bottom: 5px solid #000; border-top: 1px dotted #DDD; padding-top: 20px; padding-bottom: 15px; background-color: #CCC; }
Visual Tech
design studio
setting margins
The margin property is similar to padding, in that it also butts up to against the border. The difference is that the margin is on the outside of a tag. When you set a background color, it doesnt fill in behind the margin because its outside the border. You set the margin property the same way you do the padding that is you can set the padding for all four sides of a tag, or you can set a different padding for each of the four sides with the following properties (notice that they work just like the padding properties, clockwise starting with the top): margin-top, margin-right, margin-bottom, and margin-left. nav{ border-bottom: 5px solid #000; border-top: 1px dotted #DDD; padding-top: 20px; padding-bottom: 15px; background-color: #CCC; padding-top: 10px; padding-right: 20px; padding-bottom: 30px; padding-left: 40px; }
4.margin-left
2.margin-right
One step further looks like this: div{ padding-top: 0px; padding-right: 20px; padding-bottom: 0px; padding-left: 20px; } div{ padding: 0px 20px; }
Visual Tech
design studio
This is from http://yuilibrary.com/yui/docs/cssreset/ & like other CSS links, this goes into the head tag in your HTML file. Visit this site for more info: cssforprintdesigners.com/css-reset