Skip to content

Instantly share code, notes, and snippets.

@bekapod
bekapod / gist:2016527
Created March 11, 2012 13:58
CSS: Practical Font Sizing
/* Housekeeping */
*{ margin:0; padding:0; }
/* Define your base font-size here; most elements will inherit this. */
html{
font-size:1em; /* Assuming 16px... */
line-height:1.5; /* 24px (This is now our magic number; all subsequent margin-bottoms and line-heights want to be a multiple of this number in order to maintain vertical rhythm.) */
}
/* Common margin-bottom for vertical rhythm. */
@bekapod
bekapod / gist:2017562
Created March 11, 2012 18:28
CSS: Inline Block Hack
.inline-block {
display: inline-block;
/* IE7 hack to mimic inline-block on block elements */
*display: inline;
*zoom: 1;
}
@bekapod
bekapod / clearfix.css
Created May 8, 2012 13:00
CSS: Clearfix
.clearfix:before, .clearfix:after { content: ""; display: table; }
.clearfix:after { clear: both; }
.clearfix { *zoom: 1; }
@bekapod
bekapod / js.js
Created May 10, 2012 12:19
MAGENTO: Remotely trigger a Varien tab
Varien.Tabs = Class.create();
Varien.Tabs.prototype = {
initialize: function(selector) {
var self=this;
$$(selector+' a').each(this.initTab.bind(this));
},
initTab: function(el) {
el.href = 'javascript:void(0)';
if ($(el.parentNode).hasClassName('active')) {
@bekapod
bekapod / template.php
Created May 10, 2012 12:44
MAGENTO: Seperate add product to cart button
<!-- replace <?php echo $_product->getId() ?> with your product id if you know it, if not then this snippet is to be used in a loop of products where $_product is a reference to the catalog/product model -->
<button onclick="location.href ='<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB); ?>checkout/cart/add?product=<?php echo $_product->getId() ?>&qty=1'">Add To Cart</button>
@bekapod
bekapod / template.php
Created May 10, 2012 13:28
MAGENTO: Quick include static block on template
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block-id')->toHtml(); ?>
@bekapod
bekapod / jquery.js
Created May 22, 2012 20:32
JQUERY: Find index of an element in unordered set
$('ul > li').click(function() {
var index = $(this).prevAll().length;
});
@bekapod
bekapod / jquery.js
Created May 22, 2012 20:33
JQUERY: Object literal to define properties when creating an element
var e = $("", { href: "#", class: "a-class another-class", title: "..." });
@bekapod
bekapod / jquery.js
Created May 22, 2012 20:34
JQUERY: Hide an element that contains text of a certain value
$("p.value:contains('thetextvalue')").hide();
@bekapod
bekapod / jquery.js
Created May 22, 2012 20:35
JQUERY: AutoScroll to a section of your page
jQuery.fn.autoscroll = function(selector) {
$('html, body').animate(
{ scrollTop: $(selector).offset().top },
500
);
}
//Then to scroll to the class/area you wish to get to like this:
$('.area_name').autoscroll();