Beyond Paper Streams

Beyond Paper Streams

Nov 9 / 8:02am

Effortless Full Screen Background Images with jQuery | Design Shack

Effortless Full Screen Background Images With jQuery

2748 ► Retweet

Written by Joshua Johnson, On 5th November 2010.
Filed in JavaScript.


Today we’re going to build a simple and fun webpage for the sole purpose of showing off Fullscreenr, a great little jQuery plugin that makes it easy to add a background image to your site that automatically adjusts to the window size.

We’ll also throw in some @font-face and rgba action to keep things modern and educational on the rest of the build. Let’s get started!


Like the article? Be sure to subscribe to our RSS feed and follow us on Twitter to stay up on recent content.

Demo

Just so you can get a feel for what we’re building, check out the demo below. To see the jQuery in action, resize the browser window and watch how the image adapts dynamically.

View the demo

screenshot

Now that you’ve seen how it works, let’s build it!

Step 1: Grab Fullscreenr

screenshot

The first thing you’re going to want to do is go to the Fullsreenr website and download a copy. Grab the JS files and throw them into a folder with a basic website framework: html, css and images folder.

Step 2: Start the HTML

To begin the HTML, thrown in the code for an empty page and add the references for the stylesheet and the two JavaScript files.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
        <title>Design Shack + Fullscreenr</title>
        <!-- Stylesheet -->
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <!-- JavaScript codes -->
        <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
        <script src="js/jquery.fullscreenr.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>

Step 2: Select a Background Image

Before we insert the code for placing our background image, we’ll need to know the size. Which of course means we need to find an image.

I grabbed the image below by Faisal.Saeed on Flickr Creative Commons. It’s an awesome snowy mountain scene that should make the perfect setting for our site.

screenshot

Next, I sized the image so that it would be 907px by 680px. These are the dimensions that we’ll use in our next step.

Step 3: Insert the Fullscreenr Snippet

In the demo files of the Fullscreenr download, you should find the following JavaScript snippet to enable the plugin. I’ve customized it a bit with the image dimensions specified above.

<script type="text/javascript">  
        var FullscreenrOptions = {  width: 907, height: 680, bgID: '#bgimg' };
        jQuery.fn.fullscreenr(FullscreenrOptions);
</script>

All you have to do for your own version is change the hight and width to match that of your own image.

Step 4: Body HTML

Next up, there is a chunk of HTML in the demo page that you’ll need to grab. The structure may seem a little funky but really all the developer has done is applied the background image to the body and created a basic container (realBody) for you to then add all the rest of your content to. If you don’t like the div ID names used by the developer, feel free to change them to something more conventional.

<body>
        <!-- This is the background image -->
        <img id="bgimg" src="img/mountains-907x680.jpg" />
 
        <!-- Here the "real" body starts, where you can put your website -->
        <div id="realBody">
 
        <!-- Here the "real" body ends, do not place content outside this div unless you know what you are doing -->
        </div>
</body>

As you can see, all we’ve done here is throw in the background image.

Step 5: Add the CSS

Finally, throw in the CSS below to make everything work properly. This is necessary to make sure your content will scroll correctly and stay positioned properly in the stack.

body {
        overflow:hidden; 
        padding:0;margin:0;
        height:100%;width:100%;
}
 
#bgimg {
        position:absolute;
        z-index: -1;
}
 
#realBody{
        position:absolute;
        z-index: 5;        
        overflow:auto; 
        height:100%;width:100%;
        background: url('../img/raster.png');
}

And with that, you’re done! You should now have a background image that dynamically scales with the browser window. The transition is super smooth and works brilliantly.

screenshot

The plugin comes with an dotted pattern image overlay, shown below in a zoomed-in view. If you don’t like this effect, simply leave it out!

screenshot

If you’d like, you can stop here and proceed with your own design. If you’re interested on where to go from here, I’ll finish up with some fun design.

Step 6: Add a Background Div and Header

Now that we’ve got our background image, we want to center a div over the top of it and give it a background fill. We’ll also give it a basic header that I thought seemed appropriate given the snowy background image.

<body>
        <img id="bgimg" src="img/mountains-907x680.jpg" />
 
        <div id="realBody">
                <div id="container">
                        <h1>Welcome to Hoth</h1>
                </div>
        </div>
</body>

Next we’ll style these two elements with CSS (insert this in addition to the CSS above).

#container {
        width: 800px;
        height: 1000px;
        margin: auto;
        margin-top: 60px;
        padding-top: 10px;
        background:rgba(0,0,0,.8);
 
}
 
#container h1 {
        color:#fff;
        font-family: 'KitchenpoliceRegular', sans-serif;
        font-size:60px;
        font-weight: normal;
        text-decoration:none;
        text-align:center;
}
 
@font-face {
        font-family: 'KitchenpoliceRegular';
        src: url('KITCHENPOLICE-webfont.eot');
        src: local('‚ò∫'), url('KITCHENPOLICE-webfont.woff') format('woff'), url('KITCHENPOLICE-webfont.ttf') format('truetype'), url('KITCHENPOLICE-webfont.svg#webfontCRDciSXC') format('svg');
        font-weight: normal;
        font-style: normal;
}

This is a big chunk of code but it’s all super basic. First, we gave the container a height and width, then set the margins to auto. This gives us a vertical strip that automatically stays centered on the page. The background color for the container has been applied using rgba. This will give us a nice transparent container that lets some of that nice background image show through.

Next, we used applied some basic styles to the header and customized the font using @font-face. I used a font called Kitchen Police and an @font-face kit from FontSquirrel.

At this point, your page should look like the image below.

screenshot

Step 7: Add a Header Image

The next step is extremely easy. All you have to do is toss in an image that’s the same width as the container (800px).

<body>
        <img id="bgimg" src="img/mountains-907x680.jpg" />
 
        <div id="realBody">
                <div id="container">
                        <h1>Welcome to Hoth</h1>
                        <img src="img/walkers.jpg" />
                </div>
        </div>
</body>

And with that your image should fall right into place without any extra styling.

screenshot

Step 8: Add Some Text

In this step we’re going to add some basic filler text to the page and in the next we’ll add a grid of images. Since the text will hypothetically tie into the images, we’ll throw it all into a “grid” div.

<body>
        <img id="bgimg" src="img/mountains-907x680.jpg" />
 
        <div id="realBody">
                <div id="exampleDiv">
                        <h1>Welcome to Hoth</h1>
                        <img src="img/walkers.jpg" />
 
                        <div id="grid">
                                <h2>Good Times on Hoth:</h2>
                                <p>Lorem ipsum dolor sit amet...</p>
                        </div>
 
                </div>
        </div>
</body>

To style the text, we’ll first add a little margin to the top of the div. Then we apply basic color, size, and positioning to both the h2 tag and the paragraph tag. Notice I used some more @font-face goodness, this time with Lobster.

#grid {
        margin-top: 20px;
}
 
#grid h2{
        color: #fff;
        text-align: left;
        margin-left: 65px;
        font-size: 30px;
        font-family: 'Lobster', sans-serif;
        margin-bottom: 3px;
        font-weight: normal;
}
 
 
#grid p{
        color: #fff;
        text-align: left;
        margin-left: 65px;
        margin-bottom: 3px;
        font-size: 12px;
        font-family: helvetica, sans-serif;
        margin-top: 0px;
        width: 650px;
        line-height: 18px;
}
 
@font-face {
        font-family: 'Lobster';
        src: url('Lobster_1.3-webfont.eot');
        src: local('‚ò∫'), url('Lobster_1.3-webfont.woff') format('woff'), url('Lobster_1.3-webfont.ttf') format('truetype'), url('Lobster_1.3-webfont.svg#webfontcOtP3oQb') format('svg');
        font-weight: normal;
        font-style: normal;
}

This should give you a nicely style block of text similar to that in the image below. Now we can move onto the final step!

screenshot

Step 9: Add the Gallery

To finish the page up, we’ll toss in a simple image gallery that is basically just a grid of nine JPGs. To give the photographers credit, I’ve linked each to the original source images on Flickr.

<body>
        <img id="bgimg" src="img/mountains-907x680.jpg" />
 
        <div id="realBody">
                <div id="container">
                        <h1>Welcome to Hoth</h1>
                        <img src="img/walkers.jpg" />
 
                        <div id="grid">
                                <h2>Good Times on Hoth:</h2>
                                <p>Lorem ipsum dolor sit...</p>
                                
                                
                                
                                
                                
                                
                        </div>
 
                </div>
        </div>
</body>

As the final piece of the puzzle, we’ll toss in some margins and borders to make the image grid look nice and styled.

#grid img {
        margin: 20px 10px 20px 10px;
        border: 3px solid #000;
}
 
#grid a:hover img{
        border: 3px solid #fff;
}

That should space everything and and finish up your page! Feel free to keep going and add in a navigation section, footer, sidebar and whatever else you can think of!

screenshot

Conclusion

jQuery and the Fullscreenr plugin present the easiest and best-looking solution I’ve found for scaleable background images. If you’d rather try the same effect with CSS, check out Chris Coyier’s methods on CSS-Tricks. Chris presents three possible alternatives, the last of which uses pure CSS and works much better than other CSS attempts I’ve seen.

As always, thanks for reading. If you liked the article give us a tweet, digg or any other social shout out you can come up with!

Comments (0)

Nov 8 / 9:09am

Schedule Emails to Yourself

I live out of my email inbox.  Using GMail Apps and ActiveInbox all of my emails get sorted, which is a subject for a different post, but suffice it to say that I can see at a glance what I need to do.

One area where this system falls down is future reminders.  These are tasks that I need to check in on, but don't belong on my calendar.  I merely need to remember to do something.  For example I received a notice from the State that I may not need to file B&O tax return this year.  However, I know that something has changed and I actually will need to.  I usually remember to file B&O when the tax form comes from the state, but I'm not sure I'm going to get the form this year.  I need a reminder for January to file my taxes.

That is where NudgeMail comes in.  It is a super-easy  way to schedule an email to yourself.  There is nothing to set up - just send an email to NudgeMail with the date in the subject and voila!  It gets sent.

SnapHow explains it best:
  1. Create a new email (or forward an existing one)
  2. Set the “to:” to nudge@nudgemail.com
  3. Set the “subject:” to the day, date, or time when you want the NudgeMail to come back to you. For example, “Monday” or “Tomorrow” or “Oct 13″ or “2 hours” are all acceptable ways to send a NudgeMail
  4. Enter anything you want in the body of the email, then hit Send!
  5. *You can also use colons to set a subject for your email. For example, you can send a NudgeMail to nudge@NudgeMail.com with the subject “Tomorrow: Pick up milk”
 

Comments (0)

Sep 14 / 10:30am

QR Codes for Fun and Profit

I'm preparing for a meeting today to educate a business partner on QR codes, and I'm brainstorming uses for these little guys.

  1. Direct to your website.  Businesses can put QR codes in their windows or in their ads so users can quickly go to their site.  
  2. Chamber of Commerce.  I saw this in use in Long Beach, WA.  The Chamber issued window decals for businesses that stated the business was a member and had a QR code leading to the businesses listing on the Chamber website.
  3. Phone Number.  The QR code can contain just a phone number.  After scanning, the user can either call the number or save it to their contacts.
  4. Direct to specials. How about a QR code in advertisements directing to a web page with more information about the special - maybe even the price!
  5. Coupons.  Have a dedicated coupon page where the coupons can change but the URL stays the same.  Visitors can get instant discounts with the cashier or server getting the coupon code right from the phone.
  6. Video. How about a link to a YouTube video?
  7. Audio.  The Seattle Art Museum uses a telephone system to give more information about some art pieces.  You dial a number and then enter the extension and hear the presentation.  A QR code could lead directly to MP3 audio content that would play immediately.  I'm envisioning this at scenic waypoints, tourist sites, museums, even walking tours. 
  8. Subscriptions.  A QR code can format an SMS or MMS message (phone text messaging), an easy way for users to sign up for a contest or for updates.
  9. Text.  The codes can also just show text - up to 250 characters - good for additional explanations or directions.
  10. Walking Tour.  How about setting up a walking tour where each site has a QR code.  When scanned it leads to a web page about that feature and a map directing the visitor to the next feature.
  11. Scavenger Hunt.  Clues hidden in QR codes.
  12. Random Prize Generator.  Users scan the code, which leads them to a web page with code that randomly picks a visitor as a winner.
  13. Maps.  Link directly to a map.  This would be great if a business had moved.

QR codes can be scanned from just about any surface - even a TV or computer screen.

 

(download)

Comments (0)

Aug 30 / 10:20am

CSS is to HTML as a CMS is to… HTML | CSS-Tricks

From the desk of important beginner concepts:

You have a website with 100 pages on it. All 100 pages use the same style.css file. You’d like to change the background color of every single page. You make one adjustment in the CSS file, and that background color adjustment will be reflected across all 100 pages. You don’t need to edit each of those pages individually. That’s the core benefit behind CSS: abstracting the design away from the markup.

Now you want to make another change to those 100 pages. You’d like to include the publication date underneath the title of each of the pages. That is something you’ll need to edit the HTML to do. If those 100 pages are based on a template, as they would be when using a CMS (Content Management System), you can make one adjustment to the template file and the date adjustment will be reflected across all 100 pages. That’s the core benefit behind a CMS: abstracting the content away from the markup.

The point is that once a website is any more than one page, there are going to be shared resources and it’s time to use a CMS. Just as the zen garden taught us that using CSS is vital to allow design freedom and make redesigns easier, the ultimate freedom comes from also using a CMS where we also aren’t locked to any specific HTML. HTML isn’t for content these days, it’s for describing content. Databases are for content.

I have made this scientific chart to drive home the awesomeness of this all.

Comments (0)

Aug 24 / 9:56am

What Facebook Places Means For Small Businesses

What makes Places so important is not so much the functionality (which appears to be largely lifted from existing players), but rather the fact that it's being launched by Facebook. With over 500 million users, who are automatically opted in to the new feature, it may well be Facebook that pushes geolocation into the mainstream.

Word of Mouth and Paid Advertising For Your Business

If your business has a real-world location customers can visit, Facebook Places is another channel for word of mouth promotion, and a very powerful one at that. Every time a customer checks in to your establishment, they're automatically telling all of their friends about it. On Facebook, people's networks tend to be bigger than on geolocation services that only took off in the last year or so. Assuming their feedback is positive, this is free, word-of-mouth advertising, often with a sizable, largely local reach.

For companies who are willing to spend a few dollars for added exposure, Places is built directly into Facebook's social advertising platform, much like Pages. For those who haven't scheduled an ad campaign on Facebook, it's very easy to buy pay-per-click ads targeted to users by gender, age, interests, marital status and most importantly in this case, geography. The text and images on the ad are fully customizable, and the headline can either link to your Place, Page or company's website.

How to Get Started

If your business already has a Place set up, simply search for it via Facebook's standard search box to pull it up. Once there, you'll find a link in the lower left asking "Is this your business?" Click that to submit your claim of ownership, and Facebook will follow up via telephone to verify.

If your business is not yet on Places, you can set it up using the Facebook app on your iPhone, Android or Blackberry. Simply launch Places, click the "Check In" button and then click "Add" or "+" button to add a new location.

Have you given Facebook Places a try yet? Leave your thoughts in the comments.


Comments (0)

Aug 16 / 8:59am

Style a List with One Pixel | CSS-Tricks

A one-pixel background image can be a pretty versatile thing. With repeat-x it can be a horizontal line, repeat-y makes a vertical line, and repeat makes it a fill color. Just as a little fun proof of concept, we can use that to create a depth-chart looking unordered list:

The HTML is nothing fancy, just a nested unordered list like any other:

<ul id="project-list">
    <li>Civil Engineering
        <ul>
            <li>Cowley Hall Parking Lot Recontruction</li>
            <li>Culver’s Home Office</li>
            <li>First Addition to Highland Addition</li>
            <li>Fox Point Apartments
                <ul>
                    <li>East Side</li>
                    <li>West Side</li>
                </ul>
            </li>
            <li>Metropolitan Place Phase II</li>
            <li>Oak Park Place of Baraboo</li>
            <li>Premier Coop</li>
            <li>Sleep Inn & Suites</li>
            <li>Tradewinds Business Center</li>
            <li>UW-Madison Nielsen Tennis Stadium</li>
        </ul>
    </li>
    <li>Environmental Engineering</li>
    <li>Telecommunications Engineering
        <ul>
            <li>Nsight TeleServices (CellCom) Wisconsin</li>
            <li>Oakland County/Radian Communications Michigan</li>
            <li>T-Mobile Site Deployment</li>
            <li>U.S. Cellular Network Development</li>
            <li>Western Wireless South Dakota</li>
        </ul>
    </li>
</ul>

In the CSS, we’ll apply the single-pixel PNG graphic to the lists themselves, repeated vertically, and the list items themselves, repeated horizontally. On the list items, we can can “stop” the lines from going the whole distance across by giving the anchor links inside them a white background, which lays on top of the list item blotting out the line.

#project-list {
    background:transparent url(../images/graypixel.png) repeat-y 15px 0;
    width:340px;
}

#project-list li {
    font-size:16px;
    margin:15px 0 20px;
    padding:0 0 0 10px;
}

#project-list li a {
    background:white;
    color:#1F6DD9;
    display:block;
    padding:3px;
}

#project-list li a:hover {
    color:#84B8FF;
}

#project-list li ul li {
    background:transparent url(../images/graypixel.png) repeat-x 0 8px;
    font-size:13px;
    margin:4px 0 4px 5px;
    padding:0 0 0 20px;
}

#project-list li ul li a {
    padding:0 0 0 3px;
}

#project-list li ul li ul {
    background:transparent url(../images/graypixel.png) repeat-y 15px 0;
    margin-bottom:10px;
}

#project-list li ul li ul li {
    margin-left:16px;
    padding-left:10px;
}

View Demo

Comments (0)

Aug 12 / 8:25am

Import a Blog into Facebook via Notes, and New Application Features | HyperArts

You may have noticed that Facebook is allowing Page admins to preview to upcoming changes to Page layouts, coming into effect on August 23rd (read Facebook's announcement here). Don't worry, only Page admins can see these changes. If you have already been designing FBML tabs for the new 520 pixel width, you should be fine. But what about the standard Facebook tabs that come with every page as default applications (Notes, Photos, Discussion, Reviews)? You should take a look at the new layout for these stock tabs and see how you can best utilize them in your page marketing strategy.

Take a closer look at the Notes Tab...

This blog post will focus specifically on Notes, a blogging feature built in to all Facebook Pages and Profiles. Today I noticed the new Notes layout on Pages:

The HyperArts blog is currently being imported via the Notes function (see tutorial for this below). You can see that now the Notes tab is a central column, nested between Facebook ads on the right and the HyperArts profile photo and page info on the left. The layout has changed a bit, giving readers a preview of each note, a link to read more, and any comments left on each note.

Write a Note?

There is also a new button in the top right corner, "Write a Note," which confused me at first. Can I write a note on someone else's Page?

I looked at a Page that I do NOT admin, and saw the same button.

Well in fact, this button does not allow you to write a note for the Page you are viewing, but rather, takes you to the Notes tab of your own PROFILE. You are taken to the new Note editing interface, which has more features than the standard Facebook note or message-writing interface.

Notes Tab becoming more like a Blog

Now you can add basic formatting to your post (bullets, text formatting, etc) and preview your post or save as a draft. Facebook is really trying hard to make it easy for us to do EVERYTHING on Facebook, even blog! This seems like their newest strategy for keeping us happy within their network.

Do you even need to have your own blog anymore, if you are just going to import it into your Facebook page anyways? That's a question for another post :)

Another interesting change, is the new box in the left column, under the profile photo:

Facebook suggests that you stay within the realm of Notes and visit the Notes of your friends, or Pages that you follow. If I click on "Page's Notes" I get a stream of all the Notes written by any Page that I have "liked" on Facebook! Then, I can even choose to subscribe via RSS feed to this mega Notes stream:

Notes Search Function

In addition, there is a search field where you can find specific Notes of friends or Pages just by searching like you would in the top navigation search bar. Facebook will kindly auto-fill suggestions for you:

It is important to notice how these changes in Facebook will make your Page easier or different for users to navigate. Does this new formatting make you interested in using the Notes feature now for importing your blog?

There are some pros and cons to this method, as detailed below in the following tutorial. You should look at all options, maybe try out different applications, and see which is most user-friendly for your fans.

Tutorial: How to import your blog via Notes

To feed your blog posts into your Facebook page (to show up on the Wall and in the Notes tab) you can use the default blog import function. Follow these steps, and then I will discuss the "pros and cons" of this method, compared to other applications or the manual method:

1. Go to your Facebook page and click "Edit Page"

2. Scroll down to the Notes section of your editing interface, and click "edit"

3. On the right side of the page, you will see a gray box titled "Notes Settings." Click on the link "Import a Blog" if you are not already importing a feed (you can only import 1 blog at a time)

4. The next page you are taken to will explain how to import your blog, which is as simple as typing or pasting in your blog's URL, clicking the box to assert that you have rights to this content, and clicking "start import"

5. You will be shown an example of your feed, and if you are satisfied, click "Confirm Import"

Pros and Cons

Now, there are some benefits and some disadvantages to using this free application feature:

  • PRO: Each blog post becomes a post on your wall automatically, so your fans can "like" and comment and share your blog all within Facebook. If your post is popular, it can dramatically increase the visibility of your content across not just Facebook, but the web.
  • CON: Each post is imported into Facebook, and so fans can read your content without actually visiting your blog's site. If your goal is to increase traffic to your blog (rather than get your content seen by more eyes) then this might not be the best solution for you.

See in this image, how comments and "likes" are preserved within Facebook, but do not benefit your actual blog. There is a link back to the original post, however.

  • PRO: The Notes section of your Facebook page becomes a mini-blog, with all of your posts and any comments made by fans on the posts. The clean and easy-to-use interface is free of ads, unlike some other applications.
  • CON: The Notes import feature can take a while to actually post your content. Sometimes a few hours, sometimes a day or two. This can be an issue if you are regularly blogging and then Notes pulls in 3 posts at once. Or, if you are blogging on topical issues and time-sensitive information, and you want to share this with your fans immediately.
  • Other Applications

    Your other blog importing options include third party applications and manual posting of blog links on your wall, which guarantees that they will show up when you want them to! See this previous blog post for more information about third-party apps and importing RSS Feeds in FBML tabs.

    ShareThis

    Follow me on Twitter

    Comments (0)

    Aug 11 / 11:15am

    Ajaxian » Don’t Build from Scratch. You Now Have an HTML5 Boilerplate to Work With

    Wednesday, August 11th, 2010

    Don’t Build from Scratch. You Now Have an HTML5 Boilerplate to Work With

    The HTML5 love continues to be doled out by Paul Irish. First, he offered up Modernizr and now, he’s teamed up with Divya Manian to create an HTML5 boilerplate which leverages best practices to get your started.

    It’s essentially a good starting template of html and css and a folder structure that works. But baked into it is years of best practices from front-end development professionals. Take a peek through the source to get a feel of what’s inside. And if you think there’s too much? Delete key that badboy.

    Straight from the site, here are some of the features that make this very cool:

    • Cross-browser compatible (IE6, yeah we got that.)
    • HTML5 ready. Use the new tags with certainty.
    • Optimal caching and compression rules for grade-A performance
    • Best practice site configuration defaults
    • Mobile browser optimizations
    • Progressive enhancement graceful degradation … yeah yeah we got that
    • IE specific classes for maximum cross-browser control
    • Handy .no-js and .js classes to style based on capability
    • Want to write unit tests but lazy? A full, hooked up test suite is waiting for you.
    • Javascript profiling…in IE6 and IE7? Sure, no problem.
    • Console.log nerfing so you won’t break anyone by mistake.
    • Never go wrong with your doctype or markup!
    • An optimal print stylesheet, performance optimized
    • iOS, Android, Opera Mobile-adaptable markup and CSS skeleton.
    • IE6 pngfix baked in.
    • .clearfix, .visuallyhidden classes to style things wisely and accessibly.
    • .htaccess file that allows proper use of HTML5 features and faster page load
    • CDN hosted jQuery with local fallback failsafe.
    • Think there’s too much? The HTML5 Boilerplate is delete-key friendly. :)

    I’ve heard several people mention about getting some sort of HTML5 template to work from setup so it’s nice to see one completed and out in the wild. This should be a big help.

    The project uses everyone’s favorite source control system Github so you can grab it from there or download a zipped up file from the site.

    Posted by Rey Bango at 10:58 am 2 Comments

    -->

    2 Comments »

    Comments feed TrackBack URI

    In before everyone comments to say how much overkill this is. They’ve already declared it delete-key friendly. So instead of complaining, just don’t use what you don’t like! yay!

    Comment by SlexAxton — August 11, 2010

    Awesome. This is just the kind of thing that’ll stop me procrastinating and start writing HTML5 :)
    .
    And nice looking site to top it off! (even if it is a bit slow to scroll with all the fancy-pantsy fonts)

    Comment by Skilldrick — August 11, 2010

    Leave a comment

    Comments (0)

    Jul 16 / 2:20pm

    Textarea Tricks | CSS-Tricks

    Oh,

    1. Image as textarea background, disappears when text is entered.

    You can add a background-image to a textarea like you can any other element. In this case, the image is a friendly reminder to be nice =). If you add a background image, for whatever reason, it can break the browser default styling of the textarea. The default 1px solid bolder is replaced with a thicker beveled border. To restore the browser default, you can just force the border back to normal.

    textarea {
      background: url(images/benice.png) center center no-repeat; /* This ruins default border */
      border: 1px solid #888;
    }

    That background image might interfere with the readability of the text once the text reaches that far. Here is some jQuery that will remove the background when the textarea is in focus, and put it back if the textarea is left without any text inside.

    $('textarea')
      .focus(function() { $(this).css("background", "none") })
      .blur(function() { if ($(this)[0].value == '') { $(this).css("background", "url(images/benice.png) center center no-repeat") } });

    2. HTML5 placeholder text

    There is a new attribute as part of HTML5 forms called placeholder. It shows faded gray text in the textarea (also works for text-style inputs) which disappears when the textarea is in focus or has any value.

    HTML5 placeholder text works in Safari 5, Mobile Safari, Chrome 6, and the Firefox 4 alpha.

    3. Placeholder text, HTML5 with jQuery fallback

    We can easily test if a particular element supports a particular attribute by testing with JavaScript:

    function elementSupportsAttribute(element, attribute) {
      var test = document.createElement(element);
      if (attribute in test) {
        return true;
      } else {
        return false;
      }
    };

    Then we can write code so that if the browser does support the placeholder attribute, we’ll use that, if not, we’ll mimic the behavior with jQuery:

    if (!elementSupportsAttribute('textarea', 'placeholder')) {
      // Fallback for browsers that don't support HTML5 placeholder attribute
      $("#example-three")
        .data("originalText", $("#example-three").text())
        .css("color", "#999")
        // .attr("val", $("#example-three").text())
        .focus(function() {
            var $el = $(this);
            if ($el[0].value == $el.data("originalText")) {
              $el[0].value = "";
            }
        })
        .blur(function() {
          var $el = $(this);
          // console.log($el.text(), "value: "   $el.attr("val"));
          if ($el[0].value == "") {
              $el[0].value = $el.data("originalText");
          }
        });
    } else {
      // Browser does support HTML5 placeholder attribute, so use it.
      $("#example-three")
        .attr("placeholder", $("#example-three").text())
        .text("");
    }

    4. Remove the blue glow

    All WebKit browsers, Firefox 3.6, and Opera 10 all but a glowing blue border around textareas when they are in focus. You can remove it from the WebKit browsers like this:

    textarea {
      outline: none;
    }

    You could apply it to the :focus style as well, but it works either way. I have not yet found a way to remove it from either Firefox or Opera, but -moz-outline-style was about as far as I tested.

    REMINDER: The blue glow is becoming a strong standard and breaking that standard is typically a bad thing for your users. If you do it, you should have a darn compelling reason to as well as a similarly strong :focus style.

    5. Remove resize handle

    WebKit browsers attached a little UI element to the bottom right of text areas that users can use to click-and-drag to resize a textarea. If for whatever reason you want to remove that, CSS is all it takes:

    textarea {
      resize: none;
    }

    6. Add resize handle

    jQuery UI has a resizeable interaction that can be used on textareas. It works in all browsers and overrides the WebKit native version, because this version has all kinds of fancy stuff (like callbacks and animation).

    To use it, load jQuery and jQuery UI on your page and at its most basic level you call it like this:

    $("textarea").resizable();

    7. Auto-resize to fit content

    James Padolsey has a super nice jQuery script for auto resizing textareas. It works just how you likely hope it does. The textarea starts out a normal reasonable size. As you type more and more content, the textarea expands to include all of that text, rather than triggering a scrollbar as is the default.

    The plugin has a variety of options, but at its simplest you just load jQuery, the plugin file, and call it like this:

    $('textarea').autoResize();

    8. Nowrap

    To prevent text from wrapping normally in CSS, you use #whatever { white-space: nowrap; }. But for whatever reason, that doesn’t work with textareas. If you want to be able to type into textareas and would rather lines do not break until you press return/enter (a horizontal scrollbar is triggered instead), you’ll have to use the wrap="off" attribute.

    9. Remove default scrollbars in Internet Explorer

    IE puts a vertical scrollbar by default on all textareas. You can hid it with overflow: hidden, but then you don’t get any scrollbars at all when you expand. Thankfully auto overflow works to remove the scrollbar but still put them back when needed.

    textarea {
      overflow: auto;
    }

    Comments (0)

    Jul 9 / 5:32pm

    Get Wildcard Suggestions with a Google Autocomplete Trick

    Get Wildcard Suggestions with a Google Autocomplete Trick

    Get Wildcard Suggestions with a Google Autocomplete Trick

    Google's autocomplete is a handy tool for both saving time and getting a feel for what people are searching. Reader scantorscantor points out a cool trick for getting a bit more from the autocomplete.

    Normally, Google only autocompletes the end of a search query. If you type in a phrase and then delete the middle, though, it'll autocomplete at the place you deleted, leaving the end intact.

    Get Wildcard Suggestions with a Google Autocomplete Trick

    [via #tips]

    The author of this post can be contacted at tips@lifehacker.com


    Your version of Internet Explorer is not supported. Please upgrade to the most recent version in order to view comments.

    I've had fun with this. At one time, there was "why won't my parakeet eat my diarrhea". Unfortunately, it's been removed. For a laugh, type "i am extremely", or compare "conservatives are" to "liberals are" Reply


    So thats where David Blaine's stupid ass idea of "street magic" came from... Reply


    Good tip.. however, when I tried it over google.ca the same search criteria ends up differently - in a way inconsistent... but nevertheless helpful Reply


    This doesn't appear to work on my iGoogle page, but works great on regular ol' google.com

    I wonder how it fares in other auto completed areas...

    ~JOSh-X Reply


    I would laugh heartily if a google search turned up "how to fuck up an iPhone" in the first page of results. Reply


    Cool trick. They should make it so that entering an actual "*" wildcard performs the same thing. Reply


    In order to view comments on lifehacker.com you need to enable JavaScript.
    If you are using Firefox and NoScript addon, please mark lifehacker.com as trusted.

    Comments (0)