promotion

Friday, April 24, 2015

Foundation orbit slider inside reveal modal has no height

Orbit slider inside foundation reveal modal sets height 0 some reason. Here is the simple way to fix that issue:
$(document).on('opened.fndtn.reveal', '[data-reveal]', function(){
  $(window).trigger('resize');
});

Foundation data orbit open specific slide on load

Here is the simple way to open the the particular slide on page load:
$.fx.off = true;
$("[data-orbit-slide='"+index+"']").trigger("click");
$.fx.off = false;
Above code will first disable the jquery effects & then triggers the particular slide and then enables the jquery effect. This way we can open any slide without animation.
Note: Here index is slide number(index always starts with 0).

Sunday, April 5, 2015

How to add different styles to last row of css grid layouts

Here is the simple way to add different styles for last row elements of css grid layout.
li:nth-child(Xn):nth-last-child(-n+Y) ~ li {
}
X is the no.of columns in the grid and Y is the (no.of columns+1)
For example, we have 3 column grid layout with border bottom for each grid item, and we don't want to border bottom for last row items.
li:nth-child(3n):nth-last-child(-n+4) ~ li {
    border-bottom: 0px;
}
Ex: 4 column grid layout
li:nth-child(4n):nth-last-child(-n+5) ~ li {
    border-bottom: 0px;
}
Ex: 5 column grid layout
li:nth-child(5n):nth-last-child(-n+6) ~ li {
    border-bottom: 0px;
}
Note: Above code will only work, if you have two or more than two rows.

Sunday, March 22, 2015

get url parameters and values using jquery

Here is the simple method to get url parameters & values using jquery.
function getUrlParams() {
    var url = document.location.href;
    var params = {},hash;
    var params_arr = url.slice(url.indexOf('?') + 1).split('&');
    for(var i=0; i  < params_arr.length; i++){
      hash = params_arr[i].split("=");
      params[hash[0]] = hash[1];
    }
    return params;
  }
Above method gets the current page URL and split into parameters and their values object. For example:
http://faqspoint.blogspot.in?src=google&module=bottom
Result:
{ src : "google", module : "bottom" }
To get the values of parameters:
var source = getUrlParams()["src"];    //It will return "google"
var module = getUrlParams()["module"];    //It will return "bottom"

Saturday, March 21, 2015

How to remove index.php from codeigniter url?

Codeigniter defaultly add index.php in the url because that file is responsible for processing all requests to the system. But, we can easily remove index.php by using URL Rewriting.
Here are the simple steps:
1. Update general configuration:
Open config.php from system/application/config directory and replace
$config["index_page"] = "index.php";

with

$config["index_page"] = "";
2.Create an .htaccess file
Create a new file named .htaccess in the root directory and write below code in that file:
RewriteEngine on
RewriteCond $1 !^(index\.php|css|images|js|robots\.txt)
RewriteRule ^(.*)$ /index.php?/$1 [L]

Sunday, March 1, 2015

Horizontal line with text in the middle using CSS

Here is the simple example to create horizontal line with text in the middle. The line is created by setting a border-bottom on the containing h2 then giving the h2 a smaller line-height. The text is then put in a nested span with a non-transparent background.
HTML:
<h2><span>This is main header</span></h2>
CSS:
h2 {
   width: 100%; 
   text-align: center; 
   border-bottom: 1px solid #000; 
   line-height: 0.1em;
   margin: 10px 0 20px; 
} 

h2 span { 
    background:#ffffff; 
    padding:0 10px; 
}
OUTPUT:
This is main header

Thursday, February 26, 2015

PX to EM to PT Conversion

Here is the list of px to em conversions. These conversions are based on 16px browser default size.
PX EM Percent Points
5px0.3125em31.25%4pt
6px0.375em37.5%5pt
7px0.438em43.8%5pt
8px0.500em50.0%6pt
9px0.563em56.3%7pt
10px0.625em62.5%8pt
11px0.688em68.8%8pt
12px0.750em75.0%9pt
13px0.813em81.3%10pt
14px0.875em87.5%11pt
15px0.938em93.8%11pt
16px1.000em100.0%12pt
17px1.063em106.3%13pt
18px1.125em112.5%14pt
19px1.188em118.8%14pt
20px1.250em125.0%15pt
21px1.313em131.3%16pt
22px1.375em137.5%17pt
23px1.438em143.8%17pt
24px1.500em150.0%18pt