Skip to content

Instantly share code, notes, and snippets.

title date description keywords
First article
2019-09-10
This is the first article
first, awesome, article

Heading level 1

Heading level 2

Heading level 3

JS Study

Custom forEach function

function forEach( arr, callback ) {
  for ( var i = 0; i < arr.length; i++ ) {
    callback( arr[ i ], i, arr );
  }
}
@nicco88
nicco88 / jsNotes.js
Last active June 2, 2017 03:32
JS notes
var stringOne = "Hey there, how are you doing?",
stringTwo = "I'm doing great, thank you!";
// charAt() → it outputs the indicated index
console.log(stringOne.charAt(0));
// charCodeAt() → it returns the unicode number
console.log(stringOne.charCodeAt(0));
// concat() → it concatenates two or more strings
@nicco88
nicco88 / minicartTesting.js
Last active February 24, 2017 01:52
minicartTesting.js
// cart simulation
$('#emptyCartWarningContainer').toggleClass('displayNone');
$('.flexibleCartContent').toggleClass('displayNone');
$('ul.mainCartSections').toggleClass('displayNone');
$('ul.mainCartSections > li > a').toggleClass('displayNone');
// Script controlling cart's scrollbar
var myUl = $('#mini-shopping-cart > ul');
var timeout = null;
Centering in CSS: A Complete Guide
1. Horizontally
- Is is inline or inline-* elements (like text or links)?
-> You can center inline elements horizontally, within a block-level parent element, with just:
.center-children {
text-align: center;
}
This will work for inline, inline-block, inline-table, inline-flex, etc.
var anchored = false,
bodyH = document.querySelector('body').offsetHeight,
footerH = document.querySelector('footer').offsetHeight,
indexadv = document.querySelector('.indexadv'),
indexadvH = indexadv.offsetHeight;
var indexadvFixedBottom = indexadv.getBoundingClientRect().bottom;
var breaking = bodyH - indexadvFixedBottom - footerH - 35;
var indexadvTop = bodyH - footerH - indexadvH;
window.onscroll = function() {
// Adding jquery:
// <script type="text/javascript" src="jquery.js"></script>
// Select elements with $()
// Use .css() to style elements
$("nameOfSelector")
// Selecting with jQuery is very similar to querySelectorAll
var helpTip = document.getElementsByClassName("help-tip")[0];
var minCart = document.getElementById("min-cart");
helpTip.onclick = function() {
minCart.style.display = "block";
for (var i = 0; i < minCart.children.length; i++) {
minCart.children[i].style.display = "block";
}
}
function () {
minCart.style.display = "block";
@nicco88
nicco88 / slider.html
Last active January 12, 2017 07:18
slider.html
<!-- Title & Image Slider -->
<div class="container">
<div id="titleDiv">
<div id="title">
<img id="heartImg" src="images/brand-heart-icon.png">
<h2 id="brandTitle">Best Seller 品牌館<span id="burger">
<a href="#" data-am-offcanvas="{target: '#menu'}" class="am-menu-toggle">
<i class="am-menu-toggle-icon am-icon-reorder"></i>
</a>
</span></h2>
@nicco88
nicco88 / slider.css
Last active January 12, 2017 07:16
slider.css
/*Image Slider Div (brand.html)*/
.container {
margin: 0;
}
#titleDiv {
display: block;
margin: 0 auto;