Skip to content

Instantly share code, notes, and snippets.

View fabiorochafg's full-sized avatar

Fábio Rocha fabiorochafg

View GitHub Profile
@fabiorochafg
fabiorochafg / scrolling-page.js
Created September 11, 2019 02:05
Adding CSS class do BODY tag when page is scrolled.
$(window).scroll(function() {
if ($(this).scrollTop() == 0) {
$("body").removeClass("scrolled");
} else {
$("body").addClass("scrolled");
}
});
@fabiorochafg
fabiorochafg / overlay-background.css
Last active August 22, 2017 21:46
Overlay Background
section,
section > * {
position: relative;
}
section:before {
background: rgba(0, 0, 0, 0.5);
bottom: 0;
content: "";
left: 0;
position: absolute;
@fabiorochafg
fabiorochafg / counter.css
Created December 27, 2016 18:23
Create children counter
.counter-container {
counter-reset: number-counter;
}
.counter-container > div:before {
color: #666;
content: counter(number-counter, decimal);
counter-increment: number-counter;
display: inline-block;
float: left;
height: 30px;
@fabiorochafg
fabiorochafg / equal-columns-heights.js
Created December 27, 2016 01:48
jQuery solution to equal columns heights.
$(window).load(function(){
var altura = 0;
$(".item").each(function() {
var alturaElemento = $(this).height();
if (altura < alturaElemento) {
altura = alturaElemento;
}
});
$(".item").height(altura);
});
@fabiorochafg
fabiorochafg / form-validation.js
Created January 7, 2016 17:06
Validation form code
$("form").bind("submit",function() {
var canSubmit = true;
$(":input",this).each(function() {
var element = $(this);
var type = this.type;
var tag = this.tagName.toLowerCase();
var frase = "Por favor, preencha o campo: ";
if (type != "checkbox" || type != "radio") {
var label = $(this).prev("label").text();
var campo = label.replace(':','.');
<ul class="tabs">
<li><a href="#first">First</a></li>
<li><a href="#second">Second</a></li>
<li><a href="#third">Third</a></li>
</ul>
<div id="first"></div>
<div id="second"></div>
<div id="third"></div>
@fabiorochafg
fabiorochafg / flexbox-container.css
Last active September 29, 2022 19:43
Flexbox container
.flex-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.flex-container > .flex-item {
flex-basis: 100px;
flex-grow: 1;
flex-shrink: 0;
}
@fabiorochafg
fabiorochafg / equal-height-columns.css
Created February 19, 2015 13:55
Solution to equal height columns. It works for any column widths.
.holder {
display: flex;
}
.holder > * {
float: left;
position: relative;
}
section {
flex-shrink: 0;
width: 25%;
@fabiorochafg
fabiorochafg / multiple-columns.css
Created September 6, 2014 15:05
Allow multiple column layout (CSS only)
.columns {
overflow: hidden;
-moz-column-gap: 60px;
-moz-columns: 3 200px;
-webkit-column-gap: 60px;
-webkit-columns: 3 200px;
column-gap: 60px;
columns: 3 200px;
}
@fabiorochafg
fabiorochafg / newsletter-template.html
Last active May 3, 2017 23:35
A newsletter template.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NEWSLETTER TITLE</title>
</head>
<body>
<table width="600" style="clear:both; margin:0 auto;">
<tr>