Monthly Archives: January 2013

Loving my CSS3 Babies

Try Semtex – the new HTML5, CSS3 and JavaScript UI framework!

I am not a huge fan of roundups, but this morning, I found that I have a few pretty popular CSS3 posts and decided to put them in a single post which will be updated whenever a new one appears and is worth seeing.

How to Create a Fully Functional CSS3-only Treeview

css-3-treeview

How to Create a Fully Functional CSS3-only Tabstrip without a Single Line of JavaScript

css3-tabstrip

How to Create Semantically Correct Imageless Custom Checkboxes and Radiobuttons with CSS3

css-pages-imageless-css3-custom-checkboxes-and-radio-buttons

How to Style HTML Dropdowns with CSS3

selectbox

Creating Crossbrowser CSS3 and SVG Reflections

css3-element-reflections

How to Create iPhone Toggle Buttons with CSS3

iPhone

How to Achieve Gaussian Blur Effect with CSS3

gaussian-02

CSS3 Driven Slides Viewer Without any JavaScript

Just check this amazing presentation here.

How to Create Fancy Animated Tooltips without any JavaScript

Download CSS3 Tooltip

How to Crop Background Sprite with CSS3

css3-background-image-cropping

Fully Functional CSS3-only Tabstrip Without any JavaScript

The code for today is a fully functional CSS3-only tabstrip, which works without a single line of JavaScript and natively supports keyboard arrow navigation.

css3-tabstrip

The CSS

In short – we have a list with radio buttons, <label />s and <div />s. We hide each <div />, which is the content of the tab according to the checked state of the radio button. The <label /> is used as the button of the tab.

/*
 * @CSS3 Tabstrip
 * @author Martin Ivanov
 * @website http://wemakesites.net
 * @blog http://acidmartin.wordpress.com/
 * @twitter https://twitter.com/wemakesitesnet
 **/

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

.css3-tabstrip,
.css3-tabstrip input[type="radio"]:checked + label
{
    position: relative;
}

.css3-tabstrip li,
.css3-tabstrip input[type="radio"] + label
{
    display: inline-block;
}

.css3-tabstrip li > div,
.css3-tabstrip input[type="radio"]
{
    position: absolute;
}

.css3-tabstrip li > div,
.css3-tabstrip input[type="radio"] + label
{
    border: solid 1px #ccc;
}

.css3-tabstrip
{
    font: normal 11px Arial, Sans-serif;
    color: #404040;
}

.css3-tabstrip li
{
    vertical-align: top;
}

.css3-tabstrip li:first-child
{
    margin-left: 8px;
}

.css3-tabstrip li > div
{
    top: 33px;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 8px;
    overflow: auto;
    background: #fff;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

.css3-tabstrip input[type="radio"] + label
{
    margin: 0 2px 0 0;
    padding: 0 18px;
    line-height: 32px;
    background: #f1f1f1;
    text-align: center;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    -moz-user-select: none;
    -webkit-user-select: none;
    user-select: none;
}

.css3-tabstrip input[type="radio"]:checked + label
{
    z-index: 1;
    background: #fff;
    border-bottom-color: #fff;
    cursor: default;
}

.css3-tabstrip input[type="radio"]
{
    opacity: 0;
}

.css3-tabstrip input[type="radio"] ~ div
{
    display: none;
}

.css3-tabstrip input[type="radio"]:checked:not(:disabled) ~ div
{
    display: block;
}

.css3-tabstrip input[type="radio"]:disabled + label
{
    opacity: .5;
    cursor: no-drop;
}

The Markup

In the example below, the first tab is selected by default, because the radio button, associated with it has the checked attribute. You can set arbitrary tab to selected by default like that.

<div class="css3-tabstrip">
    <ul>
        <li>
            <input type="radio" name="css3-tabstrip-0" checked="checked" id="css3-tabstrip-0-0" /><label for="css3-tabstrip-0-0">Home</label>
            <div>
                <h3>What is Lorem Ipsum</h3>
                <p>Lorem Ipsum is simply dummy text of the printing and
                    typesetting industry. Lorem Ipsum has been the industry's
                    standard dummy text ever since the 1500s, when an unknown
                    printer took a galley of type and scrambled it to make a
                    type specimen book. It has survived not only five centuries,
                    but also the leap into electronic typesetting, remaining
                    essentially unchanged. It was popularised in the 1960s
                    with the release of Letraset sheets containing Lorem
                    Ipsum passages, and more recently with desktop publishing
                    software like Aldus PageMaker including
                    versions of Lorem Ipsum.</p>
            </div>
        </li><li>
            <input type="radio" name="css3-tabstrip-0" id="css3-tabstrip-0-1" /><label for="css3-tabstrip-0-1">About Us</label>
            <div>
                <h3>Why do we use it?</h3>
                <p>It is a long established fact that a reader will be distracted
                    by the readable content of a page when looking at its layout.
                    The point of using Lorem Ipsum is that it has a more-or-less
                    normal distribution of letters, as opposed to using 'Content
                    here, content here', making it look like readable English.
                    Many desktop publishing packages and web page editors
                    now use Lorem Ipsum as their default model text, and a
                    search for 'lorem ipsum' will uncover many web sites still
                    in their infancy. Various versions have evolved over the
                    years, sometimes by accident, sometimes on purpose
                    (injected humour and the like).</p>
            </div>
        </li><li>
            <input type="radio" name="css3-tabstrip-0" id="css3-tabstrip-0-2" /><label for="css3-tabstrip-0-2">Portfolio</label>
            <div>
                <h3>Where does it come from?</h3>
                <p>Contrary to popular belief, Lorem Ipsum is not simply
                    random text. It has roots in a piece of classical
                    Latin literature from 45 BC, making it over 2000 years
                    old. Richard McClintock, a Latin professor at Hampden-Sydney
                    College in Virginia, looked up one of the more obscure
                    Latin words, consectetur, from a Lorem Ipsum passage,
                    and going through the cites of the word in classical
                    literature, discovered the undoubtable source. Lorem
                    Ipsum comes from sections 1.10.32 and 1.10.33 of "de
                    Finibus Bonorum et Malorum" (The Extremes of Good and Evil)
                    by Cicero, written in 45 BC. This book is a treatise on
                    the theory of ethics, very popular during the Renaissance.
                    The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..",
                    comes from a line in section 1.10.32.</p>
            </div>
        </li><li>
            <input type="radio" name="css3-tabstrip-0" id="css3-tabstrip-0-3" disabled="disabled" /><label for="css3-tabstrip-0-3">Contact Us</label>
            <div>
                <h3>Where can I get some?</h3>
                <p>There are many variations of passages of Lorem Ipsum available,
                    but the majority have suffered alteration in some form,
                    by injected humour, or randomised words which don't look
                    even slightly believable. If you are going to use a
                    passage of Lorem Ipsum, you need to be sure there isn't
                    anything embarrassing hidden in the middle of text. All
                    the Lorem Ipsum generators on the Internet tend to
                    repeat predefined chunks as necessary, making this the
                    first true generator on the Internet. It uses a dictionary
                    of over 200 Latin words, combined with a handful of model
                    sentence structures, to generate Lorem Ipsum which looks
                    reasonable. The generated Lorem Ipsum is therefore
                    always free from repetition, injected humour, or
                    non-characteristic words etc.</p>
            </div>
        </li>
    </ul>
</div>

Finishing Touches

What’s left is to set width and height to the tabstrip. This should be done on the outermost element. If you have different tabstrips on the same page, you can use it’s, secondary classes, etc. In the example page, we have just one tabstrip, so we will use the base class:

.css3-tabstrip
{
    width: 440px;
    height: 220px;
}

Supported Browsers

  • Mozilla Firefox
  • Google Chrome
  • Apple Safari
  • Opera
  • Internet Explorer 9 and above

If you like this post, maybe you will follow me on Twitter or visit my personal website for other cool stuff. You can also try out the demo.

Enjoy the weekend!

Related Posts

JavaScript HTML Template Engine

Here’s a quick, dirty, reliable and library-independent client-side HTML template engine with support for prefetched templates (in a JavaScript object) and a few handy and extensible methods for compiling, adding and removing templates. Please, check the documentation in the source code and the examples at the bottom of this page for usage and more insight.

Supported Browsers

  • Mozilla Firefox
  • Google Chrome
  • Apple Safari
  • Opera
  • Internet Explorer 6-10

Please, follow @wemakesitesnet or check my website for more cool stuff.

Related Posts

HTML Markup Validation Bookmarklet

 

Try Semtex – the new HTML5, CSS3 and JavaScript UI framework!

Acid.JS Validator is a free bookmarklet that uses the W3C SGML parser’s API to validate the markup of the page on which it is called. To start using the bookmarklet, go to this page and follow the instructions.

To validate a page, simply click the bookmark and you will be presented with a detailed validation report. In you are a chrome user, you can get and install the bookmarklet from Google Web Store.

Screenshots

Validation Success

validator-valid

Validation Failure

validator-invalid

Site Cannot be Checked

validator-uncheckable

Supported Browsers *

  • Mozilla Firefox
  • Google Chrome

* More browsers will be supported soon

To get your HTML markup validation bookmarklet, go to this page and follow the instructions.

Related

Ribbonbar UI Web Component

Ribbonbar UI is by far the best recreation of the “real” desktop ribbonbar for the web. It is skinnable, fully AJAX driven component that is ready to use on any website. What you can you do with a MS Office like ribbon bar in web environment? Whether use it for navigation, associate it with your WYSIWYG editor, use in an email application, display links to your favorite social websites or simply build your entire webpage around it – this depends only on you.

ribbon-bar-xml

Ribbonbar UI has everything you would expect from a ribbonbar – cool looks, comprehensive and easy API, amazing command handling, different sets of inbuilt tools, cool Windows7 skin. And at last, but not least – deploying and configuring it is a matter of minutes.

Key Features

  • By far, the most successful recreation of the “real” desktop ribbonbar as a web component.
  • Comprehensive documentation and fun to use API.
  • Easy to modify JSON structures for tabs, ribbons and commands.
  • Imageless CSS3 skin working with all modern browsers and falling back nicely for older browsers.
  • 4 types of inbuilt tools – “toolbar”, “office menu”, “split-button” and “external”.
  • Ability to load external tools by loading them via AJAX and passing get/post parameters.
  • Small footprint.
  • Easy command handling.
  • Can be used with 3-rd party WYSIWYG editors, as a navigation component, in email systems, etc.
  • The retrieval for the JSON files can be done with any server runtime (however Ribbonbar is shipped with PHP routine only).

Supported Browsers

  • Firefox
  • Chrome
  • Safari
  • Opera
  • Internet Explorer

Screenshots

ribbonbar-ui-4

ribbonbar-ui-3

ribbonbar-ui-2

ribbonbar-ui-1

Related