How to Fix White Space Below Images (CSS)

Posted in Uncategorized on June 14th, 2012 by Robert Shea

Problem

So you’re coding out some page and you slap an image inside a div with a border. All of a sudden you notice a small gap at the bottom and you hack away at a solution.


<div style="border: 1px solid red">
    <img src="someImage.png" />
<div>

STOP!

Don’t over think the situation. Images are inline elements and have that space for descenders like g, j, q, and y.

Solution


img {
    vertical-align: bottom;
}

Depending upon your situation you may not want all images to be vertically aligned in this manner; however, that’s the only line you need to add to whatever declaration you have applied to your image. Setting your image to display: block will also fix the issue, but you’ll need to float it if you want it to still behave like an image would by default. Then you’ll need to clear that float, which means adding more markup!

Optimizing Your Loops For Scalability

Posted in Uncategorized on August 31st, 2011 by Robert Shea

Problem

In a recent project I was tasked with creating a function which would go through a list of phone numbers and identify which ones were duplicates. It seemed like a simple task which could be tackled with a for loop and some arrays; however, upon diagnosing the potential scale of the function’s usage, I determined that I needed to think this thing through quite a bit more to make it scalable.

I won’t bore you with the math, but the jist of it is that my initial instinct to use for loops and arrays would have meant my algorithm was O(n2), which means that if I put in 5 numbers, it would loop through 25 times in order to identify the duplicates. Scaling this up to 50 phone numbers would mean 250 loops!

Solution

The solution was to use objects instead of arrays, which allows me to use hash functions to point directly for what I’m searching for; the algorithm is O(n), meaning that if I put in 5 numbers, it loops 5 times. You may be wondering what exactly do I mean by “hash functions”. Here’s an analogy to help describe the difference between how to look up values in arrays and objects:

Arrays

Looking up a value in an array is like calling a list of unlabeled phone numbers looking for Bob.

Objects

Looking up a value in an object is like having a contact list with Bob’s name in it.

Example Using Arrays


function getListofDuplicatePhoneNumbersIndex(phoneNums)
{
    var dups = [], phoneNums = phoneNums;
    $.each(phoneNums, function (i)
    {
        $.each(phoneNums, function (j) {
            if(j!=i){
                if(phoneNums[i] == phoneNums[j]){
                    dups[j] = j;
                }
            }
        });
    });
    return dups;
}

Example Using Objects


function getListofDuplicatePhoneNumbersIndex(phoneNums)
{
    var seen = {}, dups = {};
    $.each(phoneNums, function(i)
    {
        var phoneNumber = phoneNums[ i ];
        if( seen.hasOwnProperty( phoneNumber ) )
        {
            dups[ i ] = true;
            dups[ seen[ phoneNumber ] ] = true;
        }else
        {
            seen[ phoneNumber ] = i;
        }
    });
    return dups;
}

If you’ve got Firebug installed or any console tool, you can observe how many loops each one takes when you click “Submit” in the Demo linked below

Demo http://wecodesign.com/demos/getDups/

Tags: , , , ,

Debugging Internet Explorer 7 CSS Glitches, The Correct Way

Posted in Uncategorized on May 6th, 2011 by Robert Shea

Problem

The result of the following code will be three list-items on a single line with a black border and no padding or spacing. However, in Internet Explorer the list-item with the clear-fix class still takes up visual space on the screen causing a gap between the list-items and the bottom border.

How would you solve this issue?

style.css
.clear-fix {
float: none !important;
height: 0 !important;
overflow: hidden !important;
clear: both !important;
display: block !important;
}

ul, ul li {
padding: 0;
margin: 0;
list-style: none;
}

ul {
border: 1px solid #000;
}

ul li {
float: left;
}

code.htm
<ul>
<li>Lorem</li>
<li>Ipsum</li>
<li>Dolar</li>
<li class="clear-fix"></li>
</ul>

Good Browsers

Bad Browsers

Solution 1

You can use targeting to set the clear-fix style to display: inline for just IE.

<style type="text/css">
<![if IE]>
.clear-fix {
display: inline !important;
}
<![endif]>
</style>

Notes: This solution requires code specific to a browser, and is required to be an embedded style-sheet, which is not ideal.

Solution 2

You can attach a class to the body tag to specify the browser, and then set a specific style.

style.css
.clear-fix {
float: none !important;
height: 0 !important;
overflow: hidden !important;
clear: both !important;
display: block !important;
}
.ie .clear-fix {
display: inline !important;
}

Notes: This solution is more ideal than the last, as it can be stored in the external CSS file; however, it requires some server side logic to determine browser type when appending the class to the body tag and it still requires code that’s specific to a browser.

Solution 3

Diagnose what the root problem is, there’s spacing, which usually means it thinks their is content, so we need to set the correct styles to counteract this. It probably thinks there’s content because of the bullet point, which we’ve disabled.

style.css
.clear-fix {
float: none !important;
height: 0 !important;
overflow: hidden !important;
clear: both !important;
display: block !important;
line-height: 0 !important;
font-size: 0 !important;
}

Notes: This solution is the best as it attacks the problem at its root. The issue is that IE7 and lower don’t auto collapse list-items when they are empty, so we have manually set the styles that the browser should’ve set to begin with.

Conclusion

The best solution to solving discrepancies in Internet Explorer is to find out what IE is supposed to be doing, and then manually specify that. Sometimes you’ll need to reorganize your code around to accommodate a rather tricky bug in IE like its z-index issue; however, in most cases you can solve it simply with CSS which is not specific to any browser. I have yet to encounter an IE bug that I’ve not been able to solve without the use of browser specific style-sheets or classes.

Useful Links

Tags: , , ,

The End of the Beginning

Posted in Announcements, Uwe Boll on January 29th, 2010 by Robert Shea

Welcome to Video Game Pulse. This may only be the start of something great to come, but I invite you to read on … wait a minute… this all sounds very familiar! Now I remember, We’ve already said all this introduction crap before. It’s been four years since my last post and there is a VERY good reason why.

Four years ago my domain expired and I wasn’t paying attention and it got sold in an auction and when I requested the domain back, the person wanted $20,000 for it; Who knew my domain was so valuable. Well, I finally got the domain back after that user let it expire; I guess it’s not all that valuable. Bottom line is this. If someone wants to buy this domain for $25,000 (inflation included) just shoot me an email.

I kid though, I am very excited to get back into writing video games news and I’m going to start off by reporting on myself! While I was importing all the old articles one by one I was reading some of the crazy things I was saying back in the day … heck, one article is even called “A Look into The Year 2010“. I’m also really excited to go back and review more of Uwe Boll’s movies now that more have been released; here is my take on House of the Dead.

Tags: , , ,

Craving For Some Sad News?

Posted in News on February 21st, 2006 by Robert Shea

Sad news is something that can strike anywhere, Be it your favorite football team losing, or you not getting that promotion, or even … a death! Death is something that is enevitable, it can and will happen to everyone, and the game industry is no exception. Games like Burnout Revenge are dedicated to people like Dr. Rabin Ezra who created the technology that makes Burnout so great!

Recently Mark “Chip” VanDeVelde, vice president of Crave Entertainment passed away. No information on his death has been confirmed so far. Mark is a person who has been in the industry for a long time and with Crave since 1998. Before Chip joined Crave, he was the national sales manager for Konami. The only solid information that I could pull up on Mark VanDeVelde was that he also worked at Dart Management Ltd., and had been invited to an Oxford event.

Visitation will be held at the McDonald-Allen-Grennan Funeral Home on Thursday, February 23rd from 5:00 p.m. – 8:00 p.m. and the Funeral service will be held on Friday, February 24th – 10:00 a.m. at St. Mary’s Catholic Church.

Mark “Chip” VanDeVelde was also a father of an 11 year old daugher, Callahan. SVG Distribution / Crave Entertainment will be starting a scholarship fund for Chip’s daughter. Below you will find the info you need to donate to this fund.

If by check make check payable to:

Crave Entertainment Group, Inc. FBO Callahan N. VanDeVelde

Please mail check to:

Crave Entertainment Group, Inc.
Attn: Lynda Broderick
4 San Joaquin Plaza Drive, Suite 200
Newport Beach California 92660

If by wire please send to:

Crave Entertainment Group, Inc.
For the benefit of (FBO): Callahan N. VanDeVelde

ABA # 121100782
Account number: 751-000373
Bank of the West
300 South Grand Avenue
Los Angeles, CA 90071.

How the DVD Killed the UMD

Posted in Critique, News, PSP on February 17th, 2006 by Robert Shea

Anyone who owns a PSP and knows what DVD’s are probably was excited to hear that movies would soon be available on a format called UMD. Soon after the hype ended we realized a problem, and it wasn’t anything small. These UMD Video’s don’t come with any extras, they can’t play on a regular DVD, and you are paying more for it then you would a DVD. Anyone who has a 2GB Pro Duo card is lucky enough to be able to just purchase the DVD and put it on the card for viewing later on.

In a not so rash and completely predicted move by Sony, they have decided to cut back on production of UMD Videos. It really makes a lot of sense, these companies aren’t selling enough of these things, and it costs to much to make them. Later on down the road when the format is cheaper to make, it will probably be more feasible. Articles such as that on Defunct Games reported on this when the system launched, their feature is titled “How the DVD killed the UMD“.

This news should not be a surprise to anyone, but what is news is that Sony wants to make the format playable on a TV, and what a better time to do it then with an addition to the PS3. Nothing has been confirmed about this speculation, but it makes enough sense. There was early rumor of a UMD burner inside the PS3, but when E3 2005 hit, and we didn’t see it that rumor kind of died off. If Sony wanted, they still may unveil a UMD player for the PS3, or a stand-alone unit.

Eventually it will become so cheap to manufacture these UMDs that the cost won’t matter. No more then 4 years ago, a DVD-R for a consumer cost anywhere between $2-5, now you can get them for pennies. A 1x DVD Burner In 2001 cost $600, a 4x in 2003 cost $300, and my brand new 16x DL-DVD Burner from 2005 cost me $30. Times change fast, and things get cheap, UMD Videos will probably be a logical step in two to three years.

Where I’ve Been; An Elaborate Excuse

Posted in Uncategorized on February 16th, 2006 by Robert Shea

As you can tell, January was a month full of updates, almost daily from the very first post. This month hasn’t really been the pillar of success when it comes to having something topical everyday. I’m still thinking of taking the weekends off, since there isn’t really any news then, but that doesn’t mean I don’t have something to say on the weekends.

Anyhow let me account for my time away from the Video Game Pulse post. I have been doing some side work programming for a wonderful gaming website called Defunct Games. As you will recall from previous posts and the expanded links section, this is a site I really like, they have fun and informative news about the gaming industry. They aren’t afraid to rip apart and correct a person, company, or magazine.

Defunct Games also has a blog which they have asked for me to make seldom posts on from time to time. I can’t argue, exposure is exposure. So don’t think someone is stealing my posts if you see some of my writing on there from time to time. Their blog is called Defunct Thoughts (also in the links section*). The blog essentially does some of the stuff I do here, but is more focused on Defunct Games main goal, which is to make the gaming industry fair and balanced.

So by now you are wondering, what is this mystery work I have been doing that has taken me away from you. I recently helped piece together a new archive over there, and a new navi which can be found on every page of Defunct Games, Check it out, roll over the buttons, have fun… let loose!

UPDATE:
*Defunct Thoughts has closed its doors and is no longer available

Prequel to Dark and Light (unreleased) In The Works!

Posted in Critique, News, PC on February 13th, 2006 by Robert Shea

MMORPG is probably one of the longest and most tongue twisting acronyms in the gaming industry. This word may strike fear in the hearts of many, and may strike happiness in others. Personally, I have never had a great MMORPG experience to justify the expense of a monthly subscription. Many of my friends; even the ones without jobs, play World of Warcraft and they constantly try to suck me into their realm. Members of my own family have gotten so addicted to these types of games that they spend hundreds a month on the game.

Massively Multiplayer Online Role Playing Game’s are something that has had roots since the early days of Phantasy Star Online and Everquest. The question you need to ask your self is simple though, have you heard of SoG? Well, from the acronym I haven’t a clue what it is. SoG is the prequel to Dark and Light. The game takes place in the land of Ganareth, where you will be part of the first territorial conquest to build the fortresses of Ysatis and Agnar. Settlers of Ganareth (SoG) is not only the prequel of Dark and Light, but it also doesn’t cost a dime!

Don’t get the wrong idea though, just because it is free doesn’t mean that it is going to suck. Many fun and great MMORPG’s start out free, many made by the Koreans. This game could suck, but it could rock, the real thing many may have to worry about is if this will eventually got to a pay service like all the other MMORPG’s of its kind.

“Settlers of Ganareth is a cost-free prelude to the most anticipated MMORPG game of 2006, Dark and Light.” said Jason Ovitt of SSPR. I’ll let you ponder that quote for a second. They are stating that it is the prelude to a game that hasn’t even been released yet. Are they going to get people hooked to the free prequel and then pull it, forcing people to continue their fix playing Dark and Light? Can this game really be called a prequel when it is coming out before Dark and Light? Wouldn’t that make Dark and Light a sequel? Maybe I’m just reading too much into it, I’m sure it will be a great baiter…. err… game.

Last week there was apparently something foul about as they tried to rebuild the Ostarian Bridge, which links players from English, French, Spanish, German, and Italian countries. It was a failed attempt to reclaim it as a free territory of Ganareth. With that, I will leave it to you to keep and eye out to see who wins the race to release. Will SoG be a prequel, or will Dark and Light be a sequel? All this and more in the wacky and wild world of miss-reporting!

Sleepless Nights in PHP Programming

Posted in Announcements on February 10th, 2006 by Robert Shea

Sorry for the lack of writing, I have been really busy with big projects that require sleepless nights and lots of PHP coding, When I am finished with the project, I shall show you my results, they are quite spectacular so far. I will be back on Monday to bring you more spectacular news. Stay Tuned and Dont Touch That Dial!

PSP ‘06, The Best is Yet To Come

Posted in News, PSP on February 9th, 2006 by Robert Shea

All the good stuff is coming out next month, so you better gear your self up for what may be the most expensive month of the year so far. If you have a PSP, then you are going to be in bliss playing some long awaited and well deserved good games. You may have noticed my very first preview on this site was for a game called Pursuit Force. Pursuit Force is a game that even the most hardened Nintendo fan will want to play. Some may shunt this off as yet another racer, but I assure you it is not, it is more of an arcade shooter then anything else, and since when could you get out of a car in a racer? Expect this game March 7.

Pursuit Force isn’t the only game hitting the block come March, you can expect to see Daxter on March 21, which may be and so far from the demo, looks to be the very first solid and very enjoyable 3D Platformer on the PSP. If that isn’t your bag, then you may want to pick up Metal Gear Ac!d 2 on March 28, it is one of the very first sequels to hit the PSP. Hell, if you don’t want any of these games, then maybe some senseless sticky ball rolling will do you some good. Me & My Katamari is the very first appearance of the Katamari Series to hit the PSP set to release March 21 along side Daxter. Some may ponder about the lack of two joysticks as did I, according to the people who played it TGS they thought it was awkward. A few months ago the game was actually released in Japan, and people changed their tune and now praise the control.

If you are looking for some good FPS action, then maybe the new Splinter Cell Essentials is for you, which releases the same day as Pursuit Force on March 7. If it is some puzzle/adventure games you are looking for, then the wonderful Worms series is what you are looking for, Worms: Open Warfare may be one of the best things to hit the PSP yet, coming March 13. If it’s sports that is up your alley, you can pick up MLB 06: The Show on February 28, which really isn’t in March at all, but its pretty damn close!

Well, that is about it for the exciting releases coming up next month, some others that you can look forward to are listed below.

Bounty Hounds, Payout Poker and Casino, World Poker Tour, Ys: The Ark of Napishtim, Dragon Ball Z: Shin Budokai, Untold Legends: The Warrior’s Code, Samurai Warriors: State of War, From Russia With Love, Stacked with Daniel Negreanu, Neopets Petpet Adventure: The Wand of Wishing, Astonishia Story, Mega Man Powered Up, Brothers in Arms, Capcom Classics Collection Remixed, Def Jam: Fight for NY: The Takeover, Mortal Kombat: Deception Unchained, Viewtiful Joe: Red Hot Rumble, Pilot Academy, OutRun 2006: Coast 2 Coast, Syphon Filter: Dark Mirror