Cesar H Castro Jr on Tumblr

  • Random
  • Archive
  • RSS
  • Any Questions
Timeline Photos | Facebookfacebook.com

That was crazy!
Pop-upView Separately

Timeline Photos | Facebook
facebook.com

That was crazy!

  • 1 day ago
  • Comments
  • Permalink
  • Share
    Tweet
World’s first Braille smartphone
Joseph Stark, techi.com
Smart phones have given millions of people easy access to information. Visually impaired consumers, however, have limited options when trying to use smart phones.That could change very soon with the release of the world’s first Braille smart phone…
Pop-upView Separately

World’s first Braille smartphone
Joseph Stark, techi.com

Smart phones have given millions of people easy access to information. Visually impaired consumers, however, have limited options when trying to use smart phones.That could change very soon with the release of the world’s first Braille smart phone…

  • 1 day ago
  • Comments
  • Permalink
  • Share
    Tweet

Introducing the Flipboard Editor

Rob Blaich, youtube.com

  • 2 days ago
  • Comments
  • Permalink
  • Share
    Tweet

Learn to count with CSS

thumbnailHidden away in the depths of the CSS specification you’ll find CSS counters. As the name suggests they allows you to count a thing on your page with CSS incrementing the value every time it appears on the document.

This is principally useful if you have a tutorial website — whether that be about cooking or web development — they all have steps to follow, and you’ll most likely have to write the step number before the actual content. CSS counters can help by doing that automatically, you can even use it to count the images on your file and add figure numbers before captions.

In this example I will be demonstrating how to achieve this by creating a simple recipe for pancakes and making CSS search for the beginning of each paragraph and adding the number of the step before it.

The HTML

<section>
	<p>Place the flour in a large bowl, make a well in the centre and pour in the milk and eggs. Give the liquid mixture a quick whisk before incorporating the flour. Continue to whisk until you have a smooth batter.</p>
	<p>Now add 1 tbsp vegetable oil and whisk thoroughly.</p>
	<p>Take a crêpe pan, or large frying pan, dip some kitchen roll in the oil and carefully wipe the inside of the pan. Heat the pan over a medium heat for one minute.</p>
	<p>Add just under a ladleful of batter to the pan and immediately start swirling it around the pan to produce a nice even layer.</p>
	<p>Cook the pancake for approximately 30-40 seconds. Use a palette knife to lift the pancake carefully to look at the underside to check it is golden-brown before turning over. Cook the other side for approx 30-40 seconds and transfer to a serving plate.</p>
</section>

The objective in this HTML is that each paragraph is a different step and with CSS we can add those dynamically by writing as little as 3 lines of code.

The CSS

CSS counters use the property counter-increment. It has been around for a while it was actually implemented in CSS 2.1, to use it we must first reset the counter’s default value to 0 before anything we want to count shows up on the page, so it’s a good idea to define this in the body styles, like so:

body {
  counter-reset: steps;  
}

This line just sets the counter back to 0 and it also names it, allowing us to later call it and also allowing us to have more than one counter on the page.

The next step is to use the pseudo element :before to target all the paragraphs and add the step number before all the text begins. To do that we need to use counter-increment, then specify the content. We can just use the number or we can append or prepend some text , in this case we’ll prepend “Step ” before the counter’s value, like so:

p:before {
  counter-increment: steps; 
  content: "Step " counter(steps) ": ";
}

We should also make this content stand out a little and to do that we’ll give it a bigger font-size than the paragraphs and make it bold:

p {
 color: #242424;
 font-family: arial, sans-serif;
 font-size: 16px;
 line-height: 20px;
}

p:before {
  counter-increment: steps; 
  content: "Step " counter(steps) ": ";
  font-weight: bold;
  font-size: 18px;
}

If you want to see this idea in action, you can see the pen I created.

Browser support

A constant concern when working with CSS is the browser support, but since this is a CSS 2.1 implementation the browser support is great: it’s supported by all major browsers, desktop and mobile , the only significant browser that doesn’t support it is IE7, and according to my stat counter IE7 is used by only 0.61% of people so I think we can say that IE7 will be departing soon. Whether or not you need to support IE7 is dependent on the stats of your own site.

Conclusion

CSS counters is not something that you will use in every project but it’s something that you should keep in the back of your mind because someday it may come in handy.

Have you used CSS counters in a project? What uses can you see for them? Let us know in the comments.

Featured image/thumbnail, counting image via Shutterstock.



AnyWP: Choose 2 WordPress Business Themes – only $18!
Learn to count with CSS


Source via Webdesigner Depot
  • 2 days ago
  • Comments
  • Permalink
  • Share
    Tweet

The Greatest Secrets of UX Revealed!

I’m a big fan of Penn and Teller, and have been for many years. I saw them live for the first time last month and was blown away by their performance.

What I really love about Penn and Teller is that they often “pull back the curtain” and reveal how they do their magic. Other magicians produce an air of mysticism and pretense around their craft, but Penn and Teller will have none of that. They know they are playing tricks, fooling the audience, and by letting everyone in on what they are doing they debunk mysticism while also (hopefully) teaching you something.

Their attitude towards their work inspired me to write an article that hopefully “pulls back the curtain” on some of user experience design’s “greatest mysteries.” Much like Penn and Teller’s mocking of “artists” like Criss Angel, I have met quite a few…read more
By Joseph Dickerson

via UX Magazine
  • 3 days ago
  • Comments
  • Permalink
  • Share
    Tweet
← Newer • Older →
Page 2 of 141

Portrait/Logo

About

Cesar H Castro Jr is a creatively witted talent.

@CesarHCastroJr is also a U.S. Marine @AskAMarine an MMA Fan @mmaconsortium a Social Media enthusiast @standardsociety and this is one of his Digital Sidebars.

Used mostly to share/bookmark random things he finds interesting.

Recommendations

Logo

.htaccess made easy contains over 200 full-color pages, meticulously crafted with large, easy-to-read text and clear graphics. Streamlined everything.

Logo

Get $10 Tees! Use Code $10TEES - Ends 9/17 10am CT - Click for Details

Logo

eBook from Rockable Press includes PDF, ePub and Kindle versions – $15 – Buy Now

Logo

eBook (PDF, ePub, Kindle) from Rockable Press – $19 – Buy Now

Logo

Spreadshirt lets you make your own t-shirt

Me, Elsewhere

  • CesarHCastroJr on Dribbble
  • @cesarhcastrojr on Twitter
  • cesarhcjr on Flickr
  • Google

Twitter

loading tweets…

Interesting

  • Quote via inothernews
    “

    Marissa (Mayer, Yahoo CEO) walked me through exactly what that would look like, what that could look like, and she showed me an opportunity for...

    ”
    Quote via inothernews
  • Photo via laughingsquid

    Beardvertising, Fuzzy Bearded Men Can Make Money By Clipping Mini Billboards on Their Beards

    Photo via laughingsquid
  • Photo via stoweboyd

    joshsternberg:

    WSJ reports Yahoo board has approved a $1.1 billion deal — in cash — to purchase Tumblr.

    Let’s see if Karp & Co accept it.

    Photo via stoweboyd
  • Photo via geeksngamers

    Adventure Time Group Photo - by sakimichan

    Photo via geeksngamers
See more →
  • RSS
  • Random
  • Archive
  • Any Questions
  • Mobile

Effector Theme by Carlo Franco.

Powered by Tumblr