Training in Web Technologies Blog

How to make a body border that was rounded inside

It does look rather confusing at first. You can’t do bizarro inside-y rounded-ness like with CSS, that’s crazy talk. But then, if you just look at it as a normal rounded corner element sitting...

Responsive Web Design Guide for Beginners

Whether you’re a beginner or a seasoned web professional, creating responsive designs can be confusing at first, mostly because of the radical change in thinking that’s required. As time goes on, responsive web design...

How to Clear Default Search String on Focus using jquery?

$(“#s”) .val(“Search…”) .css(“color”, “#ccc”) .focus(function(){ $(this).css(“color”, “black”); if ($(this).val() == “Search…”) { $(this).val(“”); } }) .blur(function(){ $(this).css(“color”, “#ccc”); if ($(this).val() == “”) { $(this).val(“Search…”); } }); Set value of field to “Search…” When field...

How to get Drop Caps using CSS3?

Cross-browser way (extra markup) Just wrap the first character of the paragraph in a span, then target the span with CSS and style away. <p> <span class=”firstcharacter”>L</span> orem ipsum dolor sit amet, consectetur adipiscing...

How to clear a file input using jQuery?

You can just clone it and replace it with itself, with all events still attached. var input = $(“#control”); function something_happens() { input.replaceWith(input.val(”).clone(true)); };

How to get triangle using CSS3?

HTML You can make them with a single div. It’s nice to have classes for each direction possibility. <div class=”arrow-up”></div> <div class=”arrow-down”></div> <div class=”arrow-left”></div> <div class=”arrow-right”></div> CSS The idea is a box with zero...

What is a standard HTML5 Page Structure?

<!DOCTYPE HTML> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ /> <title>Your Website</title> </head> <body> <header> <nav> <ul> <li>Your menu</li> </ul> </nav> </header> <section> <article> <header> <h2>Article title</h2> <p>Posted on <time datetime=”2009-09-04T16:31:24+02:00″>September 4th 2009</time> by <a...

How to get Center DIV with Dynamic Height with CSS3?

* { margin: 0; padding: 0; } #page{display:table;overflow:hidden;margin:0px auto;} *:first-child+html #page {position:relative;}/*ie7*/ * html #page{position:relative;}/*ie6*/ #content_container{display:table-cell;vertical-align: middle;} *:first-child+html #content_container{position:absolute;top:50%;}/*ie7*/ * html #content_container{position:absolute;top:50%;}/*ie6*/ *:first-child+html #content{position:relative;top:-50%;}/*ie7*/ * html #content{position:relative;top:-50%;}/*ie6*/ html,body{height:100%;} #page{height:100%;width:465px;} HTML: <div id=”page”> <div id=”content_container”>...

Lorem Ipsum Paragraph just copy and paste it

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies...

Concatenate Array for Human Reading using PHP

function concatenate($elements, $delimiter = ‘, ‘, $finalDelimiter = ‘ and ‘) { $lastElement = array_pop($elements); return join($delimiter, $elements) . $finalDelimiter . $lastElement; } Usage $array = array(‘John’, ‘Mary’, ‘Ishmal’); echo concatenate($array); // outputs “John,...

Cross-Browser hr Styling using css

hr { border : 0; height : 15px; background : url(hr.gif) 50% 0 no-repeat; margin : 1em 0; } For IE < 8 (use conditional stylesheets) hr { display : list-item; list-style : url(hr.gif)...

Cross Browser Opacity set using CSS3

.transparent_class { /* IE 8 */ -ms-filter: “progid:DXImageTransform.Microsoft.Alpha(Opacity=50)”; /* IE 5-7 */ filter: alpha(opacity=50); /* Netscape */ -moz-opacity: 0.5; /* Safari 1.x */ -khtml-opacity: 0.5; /* Good browsers */ opacity: 0.5; }

Cross Browser Inline-Block using CSS3?

li { width: 200px; min-height: 250px; border: 1px solid #000; display: -moz-inline-stack; display: inline-block; vertical-align: top; margin: 5px; zoom: 1; *display: inline; _height: 250px; }

Cookie Getter/Setter using javascript?

/** * Gets or sets cookies * @param name * @param value (null to delete or undefined to get) * @param options (domain, expire (in days)) * @return value or true */ _.cookie =...

How to get stylish Corbon Ribbon using CSS3?

<div class=”wrapper”> <div class=”ribbon-wrapper-green”><div class=”ribbon-green”>NEWS</div></div> </div> .wrapper { margin: 50px auto; width: 280px; height: 370px; background: white; border-radius: 10px; -webkit-box-shadow: 0px 0px 8px rgba(0,0,0,0.3); -moz-box-shadow: 0px 0px 8px rgba(0,0,0,0.3); box-shadow: 0px 0px 8px rgba(0,0,0,0.3);...

How to Update Values of Entire Table using PHP?

This code assumes you are connected to a MySQL database which has a table with Names and Emails. The idea is that it will output a table of every single value from that table,...

How to get Zero Padded Numbers using PHP?

function getZeroPaddedNumber($value, $padding) { return str_pad($value, $padding, “0”, STR_PAD_LEFT); } Usage echo getZeroPaddedNumber(123, 4); // outputs “0123”

Know more about the Lengths of CSS in simple steps

There are quite a few properties in CSS that take a length as a value. The box model properties are the obvious ones: width, height, margin,padding, border. But plenty of others as well: the offset and sizing of...

Automatic Table of Contents using jquery?

Any long page of content with distinct and well marked up content can benefit from a table to contents. A table of contents provides a quick way to jump down the page to the...

How to adjust Tricky Textarea Pulltab using html?

In desktop Safari, Chrome, Firefox, and Opera-under-Presto, (not IE, not mobile anything) <textarea>s have a little resizer nugget in the bottom right corner. Textareas are for writing in, so if users need more space to...

How to Check if Event was Triggered or Native?

$(‘button’).click(function(event, wasTriggered) { if (wasTriggered) { alert(‘triggered in code’); } else { alert(‘triggered by mouse’); } }); $(‘button’).trigger(‘click’, true);

How to Change Graphics Based on Season using PHP?

<?php function current_season() { // Locate the icons $icons = array( “spring” => “images/spring.png”, “summer” => “images/summer.png”, “autumn” => “images/autumn.png”, “winter” => “images/winter.png” ); // What is today’s date – number $day = date(“z”);...

How to set Custom Database Error Page in WordPress?

Put a file called “db-error.php” directly inside your /wp-content/ folder and WordPress will automatically use that when there is a database connection problem. <?php // custom WordPress database error page header(‘HTTP/1.1 503 Service Temporarily...

How to Check if Element Exists using jQuery?

Java Script if ($(‘#myElement’).length > 0) { // it exists } Or to make it a fancy function with a callback: // Tiny jQuery Plugin // by Chris Goodchild $.fn.exists = function(callback) { var...

How to make Empty Table Markup with HTML code?

<table> <thead> <tr> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody> <tr> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> </tr> <tr> <td></td> <td></td> <td></td> <td></td> </tr> </tbody> </table>