Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user's browser.
(Browser doesn't support: IE8 and below.)
Refer site: http://tympanus.net/Development/FullscreenOverlayStyles/index.html
Sunday, February 9, 2014
Modernizr plugin: Fullscreen overlay effect
Thursday, February 6, 2014
jQuery Plugin: Better scroll on desktop and mobile device
Labels:
desktop scroll,
JavaScript,
jquery,
mobile scroll,
nice scroll,
scrolling bar js
Share this post:
Tuesday, February 4, 2014
PHP: Get Url Components
Example 1: Code
<?php
$url = 'http://me:you@sub.site.org:29000/pear/validate.html?happy=me&sad=you#url';
$output = parse_url($url);
echo '<pre>' . print_r(parse_url($url), true) . '</pre>';
echo 'Path: '.$output['path'];
?>
Example 1: Output
Example 2:
To retrieve just a specific URL component as a string:
PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT
Code
<?php
$url = 'http://me:you@sub.site.org:29000/pear/validate.html?happy=me&sad=you#url';
echo parse_url($url, PHP_URL_PATH);
?>
Output
/pear/validate.html
Example 3: Code
<?php
function parseUrl ( $url )
{
$r = '!(?:(\w+)://)?(?:(\w+)\:(\w+)@)?([^/:]+)?';
$r .= '(?:\:(\d*))?([^#?]+)?(?:\?([^#]+))?(?:#(.+$))?!i';
preg_match ( $r, $url, $out );
return $out;
}
$output = parseUrl($url);
echo '<pre>' . print_r($output, true) . '</pre>';
echo 'Path: '.$output[6];
?>
Example 3: Output
Example 3: Explain output
$output[0] = full url
$output[1] = scheme or '' if no scheme was found
$output[2] = username or '' if no auth username was found
$output[3] = password or '' if no auth password was found
$output[4] = domain name or '' if no domain name was found
$output[5] = port number or '' if no port number was found
$output[6] = path or '' if no path was found
$output[7] = query or '' if no query was found
$output[8] = fragment or '' if no fragment was found
Example 4: Code
<?php
$url = 'http://me:you@sub.site.org:29000/pear/validate.html?happy=me&sad=you#url';
echo 'SERVER_PROTOCOL: '.$_SERVER['SERVER_PROTOCOL'];
echo 'SERVER_NAME: '.$_SERVER['SERVER_NAME'];
echo 'SERVER_PORT: '.$_SERVER['SERVER_PORT'];
echo 'PHP_SELF: '.$_SERVER['PHP_SELF'];
echo 'REQUEST_URI: '.$_SERVER['REQUEST_URI'];
?>
Example 4: Output
SERVER_PROTOCOL: HTTP/1.1
SERVER_NAME: sub.site.org
SERVER_PORT: 29000
PHP_SELF: /pear/validate.html
REQUEST_URI: /pear/validate.html?happy=me&sad=you#url
Example 5: Code
Example 5: Output
If current URL is:
http://www.abc.com/file/demo1/contact.html
Output will be:
http://www.abc.com/file/demo1/
Refer: http://blog.vivekv.com/php-get-the-current-url-path.html
<?php
$url = 'http://me:you@sub.site.org:29000/pear/validate.html?happy=me&sad=you#url';
$output = parse_url($url);
echo '<pre>' . print_r(parse_url($url), true) . '</pre>';
echo 'Path: '.$output['path'];
?>
Example 1: Output
Array ( [scheme] => http [host] => sub.site.org [port] => 29000 [user] => me [pass] => you [path] => /pear/validate.html [query] => happy=me&sad=you [fragment] => url ) Path: /pear/validate.html
Example 2:
To retrieve just a specific URL component as a string:
PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT
Code
<?php
$url = 'http://me:you@sub.site.org:29000/pear/validate.html?happy=me&sad=you#url';
echo parse_url($url, PHP_URL_PATH);
?>
Output
/pear/validate.html
Example 3: Code
<?php
function parseUrl ( $url )
{
$r = '!(?:(\w+)://)?(?:(\w+)\:(\w+)@)?([^/:]+)?';
$r .= '(?:\:(\d*))?([^#?]+)?(?:\?([^#]+))?(?:#(.+$))?!i';
preg_match ( $r, $url, $out );
return $out;
}
$output = parseUrl($url);
echo '<pre>' . print_r($output, true) . '</pre>';
echo 'Path: '.$output[6];
?>
Example 3: Output
Array ( [0] => http://me:you@sub.site.org:29000/pear/validate.html?happy=me&sad=you#url [1] => http [2] => me [3] => you [4] => sub.site.org [5] => 29000 [6] => /pear/validate.html [7] => happy=me&sad=you [8] => url ) Path: /pear/validate.html
Example 3: Explain output
$output[0] = full url
$output[1] = scheme or '' if no scheme was found
$output[2] = username or '' if no auth username was found
$output[3] = password or '' if no auth password was found
$output[4] = domain name or '' if no domain name was found
$output[5] = port number or '' if no port number was found
$output[6] = path or '' if no path was found
$output[7] = query or '' if no query was found
$output[8] = fragment or '' if no fragment was found
Example 4: Code
<?php
$url = 'http://me:you@sub.site.org:29000/pear/validate.html?happy=me&sad=you#url';
echo 'SERVER_PROTOCOL: '.$_SERVER['SERVER_PROTOCOL'];
echo 'SERVER_NAME: '.$_SERVER['SERVER_NAME'];
echo 'SERVER_PORT: '.$_SERVER['SERVER_PORT'];
echo 'PHP_SELF: '.$_SERVER['PHP_SELF'];
echo 'REQUEST_URI: '.$_SERVER['REQUEST_URI'];
?>
Example 4: Output
SERVER_PROTOCOL: HTTP/1.1
SERVER_NAME: sub.site.org
SERVER_PORT: 29000
PHP_SELF: /pear/validate.html
REQUEST_URI: /pear/validate.html?happy=me&sad=you#url
Example 5: Code
function getcurrentpath()
{ $curPageURL = "";
if ($_SERVER["HTTPS"] != "on")
$curPageURL .= "http://";
else
$curPageURL .= "https://" ;
if ($_SERVER["SERVER_PORT"] == "80")
$curPageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
else
$curPageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
$count = strlen(basename($curPageURL));
$path = substr($curPageURL,0, -$count);
return $path ;
}
echo getcurrentpath();
Example 5: Output
If current URL is:
http://www.abc.com/file/demo1/contact.html
Output will be:
http://www.abc.com/file/demo1/
Labels:
current url directory,
get url parameter in php,
parse a URL and return its components,
parse_url,
PHP,
url function,
url path
Share this post:
Thursday, January 2, 2014
Monday, July 22, 2013
CSS: Crop and resize image to certain ratio
Edit margin and move the image around within the <div> container.
Refer:
http://stackoverflow.com/questions/493296/css-display-an-image-resized-and-cropped
http://dabblet.com/gist/4711695
<style>
.crop {
width: 200px;
height: 150px;
overflow: hidden;
}
.crop img {
max-width: 400px;
height: auto;
margin: -75px 0 0 -100px;
}
</style>
<div class="crop">
<img src="http://img1.jurko.net/wall/paper/donald_duck_4.jpg" />
</div>
Refer:
http://stackoverflow.com/questions/493296/css-display-an-image-resized-and-cropped
http://dabblet.com/gist/4711695
Labels:
center image in a container,
crop and set image position,
crop image,
CSS,
css crop,
cut and centered image,
cut image,
different size ratio,
hide overflow,
HTML,
move image around within a div,
resize image
Share this post:
Subscribe to:
Posts (Atom)