One of the least enjoyable aspects of current website design is the need to add and subtract padding (or is it margin and also the border) from the width of elements in CSS design layouts. This post from Paul Irish goes into the border-box model and it's support in browsers.
One of my least favorite parts about layout with CSS is the relationship of width and padding. You're busy defining widths to match your grid or general column proportions, then down the line you start to add in text, which necessitates defining padding for those boxes. And 'lo and behold, you now are subtracting pixels from your original width so the box doesn't expand.
Ugh. If I say the width is 200px, gosh darn it, it's gonna be a 200px wide box even if I have 20px of padding. So as you know, this is NOT how the box model has worked for the past ten years. Wikipedia has a great history of this box model.
Anyway, I have a recommendation for your CSS going forward:
This gives you the box model you want. Applies it to all elements. Turns out many browsers already use border-box for a lot of form elements (which is why inputs and textareas look diff at width:100%;) But applying this to all elements is safe and wise.
http://paulirish.com/2012/box-sizing-border-box-ftw/ (via David Hinson)
public static void OverwriteConsoleMessage(string message)
Console.CursorLeft = 0;
int maxCharacterWidth = Console.WindowWidth - 1;
if (message.Length > maxCharacterWidth)
message = message.Substring(0, maxCharacterWidth - 3) + "...";
message = message + new string(' ', maxCharacterWidth - message.Length);
public static void RenderConsoleProgress(int percentage)
RenderConsoleProgress(percentage, '\u2590', Console.ForegroundColor, "");
public static void RenderConsoleProgress(int percentage,
ConsoleColor color, string message)
ConsoleColor originalColor = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.CursorLeft = 0;
int width = Console.WindowWidth - 1;
int newWidth = (int)((width * percentage) / 100d);
string progBar = new string(progressBarCharacter, newWidth) +
new string(' ', width - newWidth);
if (string.IsNullOrEmpty(message)) message = "";
Console.ForegroundColor = originalColor;
Console.CursorVisible = true;
Once again Jay has talked me into doing this blog thing. This time around instead of rants and whatnot I will be posting the random things I search for during the day to aid in my coding.
I ended up putting this site on my College provided web space since I have easier access to it if I do something wrong, but my first deployment was into the cloud! I found an article about hosting a BlogEngine.NET blog in the new Windows Azure Web Sites preview and it was remarkably easy and straight forward.
I've been convinced that a blog is better than twitter for posting (and most importantly finding later) bits and pieces of programming wisdom that I come across on the web. This is the result.
Thank you, Scott Hanselman.