Hacker News new | past | comments | ask | show | jobs | submit login
Bootstrap 3 Tips and Tricks (scotch.io)
207 points by _7siz on May 8, 2014 | hide | past | favorite | 48 comments



I have a hard time qualifying most of these as "tricks," which would imply some hidden or barely-utilized feature.

Most of these are quite explicitly described in the documentation (img-responsive, nested columns, responsive grids, container-fluid are all very upfront in the documentation).

And on a UX note, I cannot see any advantage to the animated, slightly expanding prettyprint code boxes. I don't think this is a valuable piece of UI.


It's easy to miss things in documentation because there is so much of it. The bootstrap documentation is really a reference utility. This article is great even for stuff that is in the documentation because you might not think to look for it.


Surprised to see this - given the amount of technical detail inherent in common Web libraries (Angular, jQuery, even jQueryUI), Bootstrap is downright lean.

You could read about every grid detail, form & UI element and JS element in less than 20 minutes.


As you know, the problem is the sheer number of libraries we use. Even if they were all as lean as Bootstrap, I will never know every tip and trick in all of them.

Thus, articles like this one have their place, and I for one thought it picked out some nice under-utilized pieces.


Really? When I first heard about Bootstrap I found it pretty easy to look at almost all of the documentation in under an hour, and it covered all of these things, except the hover dropdown, which is simple css, and the media queries.

From the first bullet point in the "Grid System":

>Rows must be placed within a .container (fixed-width) or .container-fluid (full-width) for proper alignment and padding.

Different stacking in mobile and desktop: http://getbootstrap.com/css/#grid-example-mixed Nesting Columns: http://getbootstrap.com/css/#grid-nesting Column Ordering: http://getbootstrap.com/css/#grid-column-ordering Lead class: http://getbootstrap.com/css/#type-body-copy Block Quotes: http://getbootstrap.com/css/#type-blockquotes Inline Lists: http://getbootstrap.com/css/#type-lists Inline Forms (helping screen readers): http://getbootstrap.com/css/#forms-inline Images: http://getbootstrap.com/css/#images

I guess you might not think to look for it in the documentation, but if you don't think to look for it, that means you probably aren't using it, and don't need it... I still wouldn't really call any of these things tips or tricks, it's just actually reading the documentation of what framework you're using, which apparently people don't do?


I agree up until "Different Grid Columns at Different Device Sizes". That section does not qualify as a "tip" or "trick" -- it's perhaps the most fundamental part of using Bootstrap's "grid system" layout.


Completely agree; with the exception of first item (dropdown on hover), all other items are pretty regular, documented things that are easy to understand if you are already using Bootstrap.


This is a case of "the 10000" http://xkcd.com/1053/ to me. I've only been using bootstrap for 9 months, and I learned 4+ extremely useful tips from this article.


Not to be pedantic, but as mentioned elsewhere every tip here (sans the dropdown on hover one) is in the documentation itself.

I'm really not trying to poo-poo the article but you could pluck 10 random things from Bootstrap's relatively simple documentation and have the same thing.

Maybe if it were titled "cool things in Bootstrap" instead of being presented as "tricks."


> What exactly is a "trick" then?

I'd call a trick something that is not part of the documentation core, something that has unexpected effect or behavior that was unintended initially.

None of those would apply here.


"I'd call a trick something that is not part of the documentation core .." I'd call this particular definition a pedantic, artificial nitpick invented soley for the purpose of picking nits in the post.

If on the other hand you use a conventional definition of trick, "a clever or particular way of doing something", then the post is indeed about a set of tricks.


But these aren't clever or particular ways of doing things. You're using Bootstrap's css classes to do exactly what they're designed to do.


The funny thing about your newly defined "trick" is that it would be foolish to rely on such undocumented behavior not changing on the next minor update. :)


Well the same applies to this definition of "trick" so I'm not sure that's a particularly damning point.

Either way, I didn't say such "tricks" are without peril - surely a number of jQuery "tricks," even those that were eventually canonized, have been broken over the years as the library updates.


What exactly is a "trick" then? I would argue that they're useful bits of functionality that a group of people might not know. For instance, if I post "math tips and tricks" to my facebook followers they'd be like "ooh, nice tips" but if I post them on a /r/mathematics I'd be told "they aren't tricks, that's just the way math works". I think you're just basically saying "I know this already so everyone else should too".


Math "tricks" are usually computational in nature (and so not particularly "mathematics") and while it might be obvious how they work to a mathematician, they are unlikely something the mathematician would expect to find in a textbook. (I was a math major for a few years in college, and have a ton of friends who still do research in and around mathematics today.)


+1 for the "10,000" / xkcd.com/1053 reference, that's a great one. :)

Also, for the pedants: in many English-speaking communities, "tips n tricks" is simply slang for "miscellaneous useful bits".

Finally, general props to scotch.io for being a better-than-average blog.


100% agree. Someone is pushing this site.


On HN, we aren't ashamed to "push" things we've done or written up, as long as it's not all we do here. It takes hard work to create something, and if you don't believe in it enough to push it, who will?


who is we?


The HN community.


Right, I didn't learn anything and I don't think I'm a bootstrap master.



Went to the site on my iPhone, started reading, then got pushed into the iTunes Store to a free slot app by some scummy ad.

Closed page. Didn't read.


I can't believe that Apple isn't blocking the ability for the browser to auto-open the app store. It's the absolute worst advertising experience imaginable because it actually closes the browser to open the app store.

My response to leave a 1-star rating on whatever app is being advertised with a review stating that I don't like their advertising technique.


I assume this is like pop-up blocking. You need to be able to open app store links some times (to get to the store to buy something), but you shouldn't be pushed there. But just like pop-ups, there is a big incentive for scummy advertisers to find ways around it.

I've reported this kind of thing to better websites (ones I knew/trusted) when it happened and they fixed it. I don't know if this site is fine with this or is just the victim of a terrible ad network.


It seems like it would be easy for Apple to add a confirmation like "Open in App Store?" Just like clicking on a phone number and have a confirmation before it starts dialing. Perhaps it's advantageous for Apple to keep it as-is, though?

In the meantime, I just let the advertisers know my feelings with a 1-star review. If everybody did that it would probably put an end to these pop-ups, but I won't hold my breath.


May I politely suggest that the twirling-on-scroll social icons are a bit over the top? All that motion makes them something I instinctively want to avoid.


I found this incredibly off putting as well. Especially because of how fast they spun.


I like the tips but nosying around the rest of the site some of your other content is absolutely lovely.

The chrome all-stars series is absolutely fantastic, I'm primarily a Firefox user (I've always preferred Firebug to Chrome Dev Tools) but I'm starting to realise that in a lot of ways chromes dev tools are much deeper than firebugs.

Cheers :).


If he got rid of the bar on the right it would look much better, way too much clutter currently. It's very distracting.


While presentation is important it is only one part of the overall whole and given the choice I'll take a hideous but well written piece over a beautiful article that says nothing useful.

note: I don't think this is hideous.


Heres an actual Bootstrap trick: Display placeholder text as tooltip content for focused, non-empty form inputs.

Have you ever entered information into a form that used placeholder text to tell you what to write, and you already started typing so that text disappeared but forget what you're supposed to be writing? The only way to view that placeholder text is by clearing the input field, right? Well if you have Bootstrap included already we can do some magic!

    // Display placeholder="" text as tooltip for :focused, non-empty inputs
    $('form input').blur(function() {
      var inputVal = $(this).val(),
          titleText = $(this).attr('placeholder');
      if ( inputVal !=  '' ) {
        $(this).tooltip({
          title: titleText,
          trigger: 'focus',
          container: 'form'
        });
      }
    });


Opened link, learned about .container-fluid within the first 30 seconds, life: changed. Thanks, very useful stuff!



> It will stack like this on large devices (desktop):

> And it will stack like this on small devices (tablets/phones, 768px and below):

Isn't that the default behaviour of inline HTML elements?

Honestly, most of the time I don't know what I gain by using Bootstrap, and would be very pleased if they distributted a Bootstrap-lite that only changed the default presentation of elements without all those containers, effects, and optional styles.


That's not the default behavior for inline elements. In that example with the 4 hearts, you can imagine a visually ugly effect where a browser width is narrow enough to show 3 of them and the last one drops to a new line.



Sorry guys, I didn't expect this much traffic. Working on it


Shameless plug: http://www.williamghelfi.com/bootstrap-in-practice

But I'm linking it only because in that page I offer my own tips and tricks via an email mini-course.

Beginners have found it useful.


Cool write-up!

One thing though, the hover menu doesn't really work with my Nexus 7, as it sends me straight to reddit. Hover in general assumes a mouse and doesn't work on mobile, which I'm guessing is why it was not included out of the box.


Where are the tricks? Most of them are lifted from the docs.


17 upvotes, and I've seen 4 come in while the site was down.


Is it not reasonable to expect that the people who have come back to vote have already finished reading the article?


I vote before looking at the article. Yes I've regretted it a few times, but generally I don't.


Upvoting also "saves" an article. If you look at your profile, all the posts that you upvoted are listed under a link titled "Saved stories". Voting is also intended as a save this for later. It's not unreasonable to think that some people will save this story for later, even if the site is down.


Oh wow, I absolutely never knew that. Instead I dump the ones I want to check out in my scratch file.


Aaaaaaaand it's down.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: