Skip to main content

Home/ CSS Evangelist/ Group items tagged coding

Rss Feed Group items tagged

Vernon Fowler

Web Designer Notebook » How to use Modernizr - 0 views

  • Modernizr doesn’t actually magically enable these properties for browsers that don’t support them. It just tells the page whether that feature is supported on the browser the visitor is using or not.
  • To install Modernizr, download the file from this page. Then, on your site’s head tag, add a link to the file. For example: ?1<script src="js/modernizr-1.0.min.js"></script> The second step is to include on your html tag a class of “no-js”: ?1<html class="no-js"> Why add this tag? Because that will be the default state of the page. If JavaScript (js) isn’t on, then Modernizr won’t work at all (and probably other features of your site won’t work either…), so it’s good that we have a fallback for that case. If JavaScript is indeed enabled, once that page is loaded on the browser, that class will be replaced dynamically and it may look something like this: ?1<html class="js canvas canvastext geolocation rgba hsla no-multiplebgs borderimage borderradius boxshadow opacity no-cssanimations csscolumns no-cssgradients no-cssreflections csstransforms no-csstransforms3d no-csstransitions  video audio cufon-active fontface cufon-ready">
  •  
    "There is a tool that came to make our lives as progressive web designers a bit easier: Modernizr. In this short tutorial, learn how to apply this handy script to maximum effect on your sites."
Vernon Fowler

An introduction to LESS, and comparison to Sass | Smashing Coding - 0 views

  • The only difference in variables between LESS and Sass is that, while LESS uses @, Sass uses $. There are some scope differences as well, which I’ll get to shortly.
  • With Sass, you declare @mixin prior to the style to identify it as a mixin. Later, you declare @include to call it.
  • Parametric Mixins Like having functions in your CSS (*swoon*), these can be immensely useful for those seemingly redundant tasks of modern-day CSS.
  • ...8 more annotations...
  • .border-radius( @radius: 3px ) { -webkit-border-radius: @radius; -moz-border-radius: @radius; border-radius: @radius; }
  • The syntax in Sass is very similar to that of LESS. Just use the $ for variables, and call the mixins with the @mixin and @include method mentioned earlier.
  • Selector Inheritance Here’s something not provided in LESS. With this ability, you can append a selector to a previously established selector without the need to add it in a comma-separated format. .menu { border: 1px solid #ddd; } .footer { @extend .menu; } /* will render like so: */ .menu, .footer { border: 1px solid #ddd; }
  • With LESS, you can nest ids, classes and elements as you go.
  • You can also refer in element styles to their pseudo-elements by using the &, which in this case functions similar to this in JavaScript.
  • Sass is a lot more versatile with numbers than LESS. It has built into it conversion tables to combine comparable units.
  • Sass seems to have a lot more color options — not that I would need them all. Lighten and darken are the only ones that I see myself using often.
  • Conditionals and Control This is rather nifty, and another thing not provided by LESS. With Sass, you have the ability to use if { } else { } conditional statements, as well as for { } loops. It supports and, or and not, as well as the <, >, <=, >= and == operators.
Scott Hendrickson

A List Apart: Articles: Frameworks for Designers - 0 views

  • How should a CSS framework be built? There are several possible ways to go about building a framework, but the most common and arguably the most useful is to abstract your common CSS into individual stylesheets that each cover a particular part of the whole. For example, you may have a stylesheet that sets up the typography and another that handles the mass reset. The beauty of the approach is the ability to selectively include only the styles that you need. You may end up with six or seven different stylesheets in your framework, but if a particular project doesn’t need one or two of them, they don’t have to be included. The framework we created in our office has five stylesheets: reset.css—handles the mass reset. type.css—handles the typography. grid.css—handles the layout grid. widgets.css—handles widgets like tabs, drop-down menus, and “read more” buttons. base.css—includes all the other stylesheets, so that we only need to call base.css from our (X)HTML documents to use the entire framework.
  • A word of caution This method works quite well, but there is a valid concern to be raised: it adds to the number of HTTP connections needed to render each page. On large, high-traffic sites, adding five more HTTP connections to every page view may result in angry system administrators. Two possible solutions to this are: Include everything in a single file, rather than breaking it into modules. The problem here is that you lose the ability to include only certain parts of the framework, and you also make maintenance more difficult. Have a server-side process that dynamically flattens the individual files into a single response. I’ve not seen this done, but it could be very efficient if done well. Using my example framework above, this dynamic process could occur when base.css is requested, but not when type.css, grids.css, etc. are. This way, the individual components are still available, but the entire framework is available in a flattened version, as well.
Vernon Fowler

bjankord/Style-Guide-Boilerplate - 0 views

  • I recommend creating a directory named style-guide in your site's root directory. I think it would be awesome if I could go to anysite.com/style-guide/ and check out that site's style guide.
  • You should be able to go to yoursite.com/style-guide/ and see how your live site's CSS affects base elements.
  • Below the custom styles for the boilerplate, you will add in your own custom stylesheet(s) which you use on your live site.
  • ...1 more annotation...
  • To create custom patterns like buttons, breadcrumbs, alert messages, etc., create a new .html file and add your HTML markup into the file. Save the file as pattern-name.html into the markup/patterns directory inside of your style-guide directory.
Vernon Fowler

Choosing great variable names - 0 views

  • try to choose semantic names for your variables
  • describe its function or purpose
  • // Better $brand-color: red; $accent-color: yellow;
  • ...3 more annotations...
  • postfix color names with -color:
  • add a prefix like header- or footer- for specific sections: // Header $header-height: 100px; $header-background-color: $color-brand; // Footer $footer-height: 200px; $footer-background-color: #aaa;
  • I like to keep all my variables in a single file, called _config.scss, that I include in my primary stylesheet using the @import directive.
Vernon Fowler

Font sizing with rem - Snook.ca - 0 views

  • The problem with em-based font sizing is that the font size compounds. A list within a list isn't 14px, it's 20px. Go another level deeper and it's 27px!
  • The rem unit is relative to the root—or the html—element. That means that we can define a single font size on the html element and define all rem units to be a percentage of that. html { font-size: 62.5%; } body { font-size: 1.4rem; } /* =14px */ h1 { font-size: 2.4rem; } /* =24px */
  • We can specify the fall-back using px, if you don't mind users of older versions of Internet Explorer still being unable to resize the text (well, there's still page zoom in IE7 and IE8). To do so, we specify the font-size using px units first and then define it again using rem units. html { font-size: 62.5%; } body { font-size: 14px; font-size: 1.4rem; } /* =14px */ h1 { font-size: 24px; font-size: 2.4rem; } /* =24px */
  • ...3 more annotations...
  • I'm defining a base font-size of 62.5% to have the convenience of sizing rems in a way that is similar to using px.
  • consistent and predictable sizing in all browsers, and resizable text in the current versions of all major browsers
  • The compounding nature of em-based font-sizing can be frustrating so what else can we do?
Vernon Fowler

Replacing the -9999px hack (new image replacement) - Jeffrey Zeldman Presents The Daily... - 0 views

  • My friend Scott Kellum, design director at Treesaver, has now sent me this refactored code for hiding text, which I hereby christen the Kellum Method: .hide-text { text-indent: 100%; white-space: nowrap; overflow: hidden; } Really long strings of text will never flow into the container because they always flow away from the container. Performance is dramatically improved because a 9999px box is not drawn. Noticeably so in animations on the iPad 1.
  • Scott Kellum said on 1 March 2012 at 3:41 pm: I went ahead and created a side by side site to test the performance: http://lab.pgdn.us/hidden-text-performance/ @Ethan, This is the best 43min I have ever spent learning about optimizing the performance of my CSS: http://www.youtube.com/watch?v=xuMWhto62Eo
  • Would be interesting to understand both the SEO and accessibility impacts of this approach.
  • ...4 more annotations...
  • Scott Kellum said on 2 March 2012 at 4:06 pm: After much deliberation over here: https://github.com/h5bp/html5-boilerplate/issues/1005#issuecomment-4293007 Jonathan Neal suggested a method using font: 0/0 serif; and things seem to be settling on this — .ir { font: 0/0 serif; text-shadow: none; color: transparent; }
  • While I think this is certainly and interesting approach, I have some concerns with the accessibility. In some, if not all, cases when overflow: hidden; hides the content of the element this is applied to from screen readers. In most cases where I use image replacement, I still need the text to be accessible (e.g. call to action buttons set in Gotham). See Aaron Gustafson’s A List Apart article, http://www.alistapart.com/articles/now-you-see-me/. Has anyone tested this with a wide battery of screen readers or other accessibility devices?
  • Another note on accessibility: Besides the screen reader problems – people who don’t get images will not see the text too.
  • As a few people said already, this does not solve the accessibility problem that comes with text-indent. Worse, it may send the wrong message: “this is new and cool, use this from now!”. As a leader in the industry, I think you should warn people that even if this is “better” in term of performance, it is still a bad solution. Imo, Image Replacement techniques should be evaluated against the problems they solve/address. Fwiw, I wrote something about these challenges a few years back: http://tjkdesign.com/articles/tip.asp </shameless plug>
Vernon Fowler

Box Sizing | CSS-Tricks - 0 views

  • The box-sizing CSS3 property can do just this. The border-box value (as opposed to the content-box default) makes the final rendered box the declared width, and any border and padding cut inside the box.
  • -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ -moz-box-sizing: border-box; /* Firefox, other Gecko */ box-sizing: border-box; /* Opera/IE 8+ */
Wanda Terral

Patternify | CSS Pattern Generator - 0 views

  •  
    Patternify is a simple CSS pattern generator. Its graphical web-based interface lets you draw the pattern you want, and then it generates the CSS code for you. Instead of having to launch your graphics editor and creating a 2px by 2px image, you can just build your pattern online using this. And with the base64 code, you don't even need an image file anymore: just include the code in your CSS and you're ready to rock.
Vernon Fowler

The CSS Property Value inherit » Learn CSS3 | Cheat Sheet | CSS Tutorial | Se... - 0 views

  • Internet Explorer 7 and earlier versions don’t support the value inherit for any properties other than direction and visibility.
Perry Branch

mezzoblue § CSS Crib Sheet - 0 views

  • Name classes/IDs based on function, not appearance. If you create a .smallblue class, and later get a request to change the text to large and red, the class stops making any form of sense. Instead use descriptive classes like .copyright and .pullquote.
  • When in doubt, validate.
  • When relying on floats for layouts, make sure they clear properly.
Vernon Fowler

A Complete Guide to Flexbox | CSS-Tricks - 0 views

  • flex-direction
  • flex-wrap
  • space-around: items are evenly distributed in the line with equal space around them
  • ...6 more annotations...
  • justify-content
  • align-items
  • flex-start: cross-start margin edge of the items is placed on the cross-start line
  • stretch (default): stretch to fill the container (still respect min-width/max-width)
  • Note: this property has no effect when the flexbox has only a single line.
  • flex-grow
yc c

Shell Editor | MooShell | to test your JavaScript code - 4 views

shared by yc c on 30 Jan 10 - Cached
  •  
    MooShell is a shell editor where you can write your JavaScript, HTML and CSS code and run it. It might prove to be useful in various cases where you need to test your code without reloading your browser.
Vernon Fowler

No More Need For Some CSS3 Vendor Prefixes | MightyMeta - 0 views

  • Safari (5% of global share) still requires a prefix for box-shadow
  • Hopefully some of the other more exciting CSS3 properties such as transform will follow suit soon.
Vernon Fowler

LESS « The Dynamic Stylesheet language - 0 views

  • It is possible to output rules in your CSS which allow tools to locate the source of the rule. Either specify the option dumpLineNumbers as above or add !dumpLineNumbers:mediaQuery to the url.
yc c

24 ways: Flickr Photos On Demand with getFlickr - 0 views

  •  
    A script (.js + .css files to download) that will generate a gallery to an HTML link as you use the CSS class getflickrphotos.
my mashable

Disable YouTube's related videos With a Simple Hack Code - 0 views

  •  
    Disable YouTube's related videos With a Simple Hack Code - YouTube added the feature "related videos" wayback in 2007. Iam sure every YouTube user come across with this feature. Once the video completes playing, will displays a list of related videos..." />
Gary Edwards

Introducing LESS: a Better CSS « Usability Post - 0 views

  •  
    Some bright folks also feel the same pain and went ahead and built meta-languages and compilers that take their own version of CSS and compile it to standard CSS code. Their own CSS meta-language is thus able to have new features, like variables, mixins, operations and so on. The most notable of these right now is SASS (part of HAML). I've tried SASS and really liked it, but one thing really bothered me. I didn't like how all the syntax was different to CSS. Sure, it's not CSS anymore, it's SASS, but do we really need to change the syntax of the stuff already present in CSS - why not just expand it? I've asked a friend of mine who is much more competent at programming than me about how long it would take to code a CSS compiler that retained the original CSS syntax but added a bunch of new features. He liked the idea and so we've put together our own version of CSS together with a compiler we call LESS, which stands for Leaner CSS.
Vernon Fowler

Get Started with Font Awesome - 0 views

  • Super-simple upgrades Since each site gets a unique embed code, you can easily upgrade to the latest version of Font Awesome, all without pushing any code. Easy peasy.
1 - 20 of 129 Next › Last »
Showing 20 items per page