Tag: dyssahagun.com

  • Center-align lists

    It’s easy to center-align a bunch of text:

    [code lang=”html” title=”HTML”]
    <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</p>
    [/code]

    [code lang=”css” title=”CSS”]
    p {text-align:center;}
    [/code]

    But how do you center-align a list such as a ul or an ol with children set as inline (or side by side)?

    Simply set the parent (ul) to text-align:center and the children (li) to display:inline-block

    [code lang=”html” title=”HTML”]
    <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Contact</a></li>
    </ul>
    [/code]

    [code lang=”css” title=”CSS”]
    ul {
    list-style:none;
    margin:0;
    padding:0;
    text-align:center;
    }

    li {display:inline-block;}
    [/code]

    This is useful for footer links displayed in mobile browsers wherein you want texts to center-align.

    See a demo at CSSDesk

  • Design principle #1: set defaults

    Avoid making the user choose from too many options.

    Do: set default options for users to choose from–ideally the most common and provide a way for them to choose what is not initially presented.

    Design principle #1: choose a default

    Avoid: presenting a wide array of options that the interface gets cluttered and the users confused on which to choose.

    Design principle #1: choose a default

    Choose the most common/natural path for the users.

    Do: set default actions in the context of the task while still making other actions available.

    Design principle #1: set a default

    Avoid: cramming available actions altogether; provide importance to actions which are more contextual than others.

    Design principle #1: set a default

    Design principles are not rules to abide by but more of guidelines in designing products for users. They should be put in context and tweaked when necessary.

  • Trying out Brackets for front-end development

    For the longest time, I’ve been using Adobe Dreamweaver and Notepad++ in developing the front-end of websites (and I remember trying out PageMill long ago and resorted to Notepad).

    I’m looking into one of Adobe’s projects: Brackets.

    Brackets
    A photo of the Brackets screen in Windows 7.

     

    Brackets is an open-source editor for web design and development built on top of web technologies such as HTML, CSS and JavaScript. The project was created and is maintained by Adobe, and is released under an MIT License.

    Source: http://brackets.io/

    It could be the middle ground between Dreamweaver and Notepad++–we’ll see.

  • CSS, I could see what you’re doing there…

    …you’re translating all the features and functions of all software combined into styles and you’re making the browser a mashup of those software.

    CSS, I could see what you're doing there

    One day, Photoshop will have an “export to HTML and CSS” function wherein the lens flare filter I dearly love would be a bunch of vector shapes rendered by the browser.

    And whenever I see the need to make the lens flare in my image more awesome, I could easily tweak it:

    [code lang=”css” title=”CSS”]
    img {
    lens-flare-type:35mm-prime;
    lens-flare-brightness:100%;
    }
    [/code]

    By then, writing the stylesheet might become as easy as spelling my name in binary code due to its vast properties and values.

    Then we’ll be back to GUIs again.

  • CSS Regions–we’re waiting for you

    Your content will flow through various containers (called regions) which you specify.

    The CSS regions module allows content to flow across multiple areas called regions. The regions are not necessarily contiguous in the document order. The CSS regions module provides an advanced content flow mechanism, which can be combined with positioning schemes as defined by other CSS modules such as the Multi-Column Module [CSS3COL] or the Grid Layout Module [CSS3-GRID-LAYOUT] to position the regions where content flows.

    Source: http://dev.w3.org/csswg/css-regions/

    CSS Regions
    An analogy of CSS Regions using a faucet and water flowing through interconnected containers.

    Imagine a magazine layout where you could have multiple columns in your article or where the cut of a paragraph continues to the next page.

    With all these CSS developments going on, one could really build a web app based on HTML and CSS as its front-end.

    We’re really in the 21st century.

    Also, checkout Adobe & HTML’s page on CSS Regions.

  • The browser unifies content. It forces us to adhere to standards.

    Imagine a time wherein your doodles in Paper could be opened and edited freely in Illustrator then shared instantly on the web–all these would be possible if they would be speaking in discernible language.

  • We’re waiting for position:sticky

    Sounds like booger? Nope, it’s what’s been brewing in browsers and hopefully it becomes a standard. The basic syntax is:

    [code lang=”css” title=”CSS”]
    div {position:sticky;}
    [/code]

    We already have position:fixed and it sticks!

    Well, if you’re familiar with the CSS propety-value position:fixed, it fixes the position of an element relative to the viewport (and not its parent element)–so that when you scroll the screen, the element stays where you tell it to. That’s one of its caveats: it escapes any parent and becomes relative to the viewport or in other words, it escapes the layout.

    position:fixed sticks but we don’t have much control over it like if we want the element to be contained to its parent element. On the other hand, position:sticky is more like position:absolute (the power of being relative to its parent) + position:fixed (the power to stay where you tell it to).

    An illustration of element with different position property values.
    An illustration of elements with different position property values.

    What’s more to sticky?

    The proposal is that you could define its top, right, bottom, and left values to be detected relative to the viewport–and this is the time when sticky will be activated. For example:

    [code lang=”css” title=”CSS”]
    div {
    position:sticky;
    top:10px;
    }
    [/code]

    Wherever this div is located, when you scroll the screen and this element is exactly 10px from the top of your viewport, it will become sticky so that when you scroll farther away, that element stays in your view (you can do this to position:fixed but with the help of JS for the activation part).

    One last thing, I propose it be named, stick as in, position:stick.

  • Minify and un-minify CSS

    Whether you have an unreadable stylesheet or you want to minify/compress it for optimization purposes, Client-side CSS (De)Compressor is your friend.

    Update: since the previous tool doesn’t exist anymore, here’s another tool to unminify your CSS:

  • Setting the width of absolutely-positioned elements

    One way to set the height of an element to 100% is to absoultely-position it yet you needed a max-width for it to follow (instead of a simple width) for layout reponse purposes.

    The solution is to simply set its width to 100% and set the max-width to your desired value. For example:

    [code lang=”css” title=”CSS”]
    div {
    position:absolute;
    width:100%;
    max-width:1280px;
    height:100%;
    background-color:red;
    }
    [/code]

  • 100% parent, definite-width child

    You want to have a 100% expanding parent while still having control over the child to have a definite width?

    What’s the use for this? A 100% background not interfering with the child that has width.

    [code title=”HTML” lang=”html”]
    <div class="container">
    <div class="content">
    Content
    </div>
    </div>
    [/code]

    [code title=”CSS” lang=”css”]
    .container {
    background-color:red;
    }

    .content {
    margin:0 auto; /* To center the div */
    max-width:960px; /* To make it responsive in viewports smaller than 960px */
    }
    [/code]

    And you can even add box-sizing:border-box to the content!

    [code title=”CSS” lang=”css”]
    .content {
    max-width:960px;
    box-sizing:border-box; /* Don’t forget to add the vendor prefixes */
    }
    [/code]