Skip to content

Instantly share code, notes, and snippets.

@teeaich
teeaich / unwatch_angular
Created August 13, 2013 15:25
unwatch an expression in angular
var watcher = $scope.$watch('data.counter', function(newValue, oldValue) {
iElement.css('width', 50 * newValue + 'px');
if (newValue >= 10) {
// autodestruction when data.counter reaches 10
watcher();
}
});
@teeaich
teeaich / appear_left_right
Created August 13, 2013 13:16
simple content appearing from left and right when trigger class is set (for example scrolling)
.cbp-so-init .cbp-so-side {
opacity: 0;
-webkit-transition: none;
-moz-transition: none;
transition: none;
}
.cbp-so-init .cbp-so-side-left {
-webkit-transform: translateX(-80px);
-moz-transform: translateX(-80px);
@teeaich
teeaich / iframe
Created July 31, 2013 14:24
get specific iframe with ID
function getFrameForDocument(document,id) {
var w= document.defaultView || document.parentWindow;
var frames= w.parent.document.getElementsByTagName('iframe');
for (var i= frames.length; i-->0;) {
var frame= frames[i];
try {
if (frame.id===id)
return frame.contentDocument || frame.contentWindow.document;
} catch(e) {}
}
@teeaich
teeaich / iframe
Created July 31, 2013 14:24
get document of own iframe
function getFrameForDocument(document) {
var w= document.defaultView || document.parentWindow;
var frames= w.parent.document.getElementsByTagName('iframe');
for (var i= frames.length; i-->0;) {
var frame= frames[i];
try {
var d= frame.contentDocument || frame.contentWindow.document;
if (d===document)
return frame;
} catch(e) {}
@teeaich
teeaich / center_content
Created July 11, 2013 17:26
center content height and width
.centered {
position: fixed;
top: 50%;
left: 50%;
margin-top: -50px; /* half the height of the element */
margin-left: -100px; /* half the width of the element */
}
/* when content has percentage size */
@teeaich
teeaich / aspect_ratio
Created July 11, 2013 17:19
aspect ratio
/* for normal inline-block element like a img */
/* nothing special */
img{
min-width: 100%;
height: auto;
}
/* for any element like a div
html markup should be
@teeaich
teeaich / style_links
Created July 4, 2013 18:39
style links based on filetype
@teeaich
teeaich / min_height
Created July 4, 2013 18:37
cross browser minimal height
#container {
min-height: 550px;
height: auto !important;
height: 550px;
}
@teeaich
teeaich / column_divider
Created July 4, 2013 18:35
columns divider CSS3
#columns-3 {
text-align: justify;
-moz-column-count: 3;
-moz-column-gap: 12px;
-moz-column-rule: 1px solid #c4c8cc;
-webkit-column-count: 3;
-webkit-column-gap: 12px;
-webkit-column-rule: 1px solid #c4c8cc;
}
@teeaich
teeaich / list_bullets_triangles
Created July 4, 2013 18:31
list bullets - triangles
ul {
margin: 0.75em 0;
padding: 0 1em;
list-style: none;
}
li:before {
content: "";
border-color: transparent #111;
border-style: solid;
border-width: 0.35em 0 0.35em 0.45em;