Category Archives: HTML 5

Make a simple arrow with CSS.

The Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language.
The goal of this tutorial is focused around providing an intuitive way to understand the steps of using CSS.
First we can make one arrow design into two steps – the first and the last part of the arrow and the inner arrow.
We need two div tags. and for each of this will add two class: arrow and inner-arrow. The text is: Far away !!!.
The CSS will be into style tag into the head tag area.
The div.arrow will start for all with font-size:0 – see also the open and close {}.
The style for an element can be specified in many different places.
The CSS Style Rule Syntax as follows is this:

You can put many properties on selector.
Also we can used :before and :after, with which you can place text or an image before and after each HTML element.
Also you can take a look at CSS3 docs. where come with :: , see ::before and ::after.
Try to see all the properties and values from my example and if you don’t understand then open this link – w3schools.
You will find all of you need.

Posted in All, HTML 5, Programming. Tagged with , , , .

Random circles with jQuery.

If you don’t understand all of my tutorials then you need to take a look of this tutorial.
You need a default html5 template. Into this html5 will add the css – Cascading Style Sheets, link to jQuery, and our javascript.
You need to include into project the jQuery. Download the jQuery from internet and put into same folder with your html5 file.

You need to put css for each html tag and will do that with:

Into body tag will put the window canvas and the javascript to draw into canvas.
First after body tag will come with:

The next step is to draw into canvas with javascript by using canvas into 2D – dimensions:

The basic issue is to fill the webpage with circles. All circles will be make random with this parameters: color, x, y, radius, orbit and speed.

All circles will be make like one array:

You need also to make all vars and this functions: r256, reset, resize, render.
When you used render function then you need to put also this function: requestAnimationFrame(render);
The r256 is one function for random up to 256. Is used most for colors ( red – green – blue ) range.
The reset function will make 160 circles.
The resize will resize the canvas with circles.
The render function will clean, fill and move all circles and then will make another frame for us with requestAnimationFrame function.
All variables and math functions is used for draw and show the canvas, circles, move and color stuff.
I don’t want to explain this steps because is very simple and also the goal is to understand the basic structure of the script.
Let’s see the full source code.

Posted in All, HTML 5, javascript, Programming. Tagged with , , , .

Rate this with jQuery.

The main index.html file come with this source code:

<!doctype html>
<html>
<head>
<meta charset=”utf-8″>
<title>Emoticons – rate this …</title>
<link href=”ratethis.css” rel=”stylesheet” type=”text/css” />
<script src=”jquery-2.2.0.js”></script>
<script src=”ratethis.js”></script>
</head>
<body>
<br/>
<br/>
<br/>
<br/>
<br/>
<input type=”hidden” value=”amo” class=”rate_it”/>
<script>
$(‘.rate_it’).ratethis(); </script>
</body>
</html>

The ratethis.css come with this source code:

.ratethis  { display: none;padding-bottom:8px;padding-top:8px;padding-right: 8px;
padding-left: 0px;box-sizing: border-box;background: white;color: white;position: absolute;
width: auto;height: 65px;line-height: 25px;border-radius: 50px;transition: .25sease-in-out;color:black;
border: 1px solid #eee;
-webkit-box-shadow: 4px 4px 21px -9px rgba(0,0,0,0.75);
-moz-box-shadow: 4px 4px 21px -9px rgba(0,0,0,0.75);
box-shadow: 4px 4px 21px -9px rgba(0,0,0,0.75);}

.ratethis  div{margin-left: 8px;float: left;width: 48px; height: 48px; cursor: pointer; transition: all 0.2s ease;}
.selectorFace{margin-left: 8px;float: left;width: 48px; height: 48px; cursor: pointer; transition: all 0.2s ease;}
.ratethis  div:hover{ -webkit-transform:scale(1.25);-moz-transform:scale(1.25);-ms-transform:scale(1.25);-o-transform:scale(1.25);transform:scale(1.25);}

.molesto{ margin-left: 8px;float: left;width: 48px; height: 48px; background: url(test.png) 0 0; }
.asusta{background: url(test.png) 0 -48px; }
.divierte{background: url(test.png) 0 -96px; }
.gusta{background: url(test.png) 0 -144px; }
.amo{background: url(test.png) 0 -192px; }
.triste{background: url(test.png) 0 -240px; }
.asombro{background: url(test.png) 0 -288px; }
.alegre{background: url(test.png) 0 -336px; }

.MessageText{display:none;position:absolute;border:1px solid #333;background-color:#161616;
border-radius:5px;padding:3px;color:#fff;font-family: sans-serif;font-size: 12px;}

.IconoPequenio{width: 24px;height: 24px; background-size: 24px; background-repeat: no-repeat;}

The javascript file ratethis.js come with this source code:

$.fn.extend({ratethis: function(options) {

var ratethis=this;
var varSelect=”Selector”;
var icon_description=”–“;
defaults = { allicons:[
{“emocion”:”amo”,”TextIcon”:”I love him”},
{“emocion”:”molesto”,”TextIcon”:”It bothers me”},
{“emocion”:”asusta”,”TextIcon”:”It scares me”},
{“emocion”:”divierte”,”TextIcon”:”I enjoy”},
{“emocion”:”gusta”,”TextIcon”:”I like it”},
{“emocion”:”triste”,”TextIcon”:”It saddens me”},
{“emocion”:”asombro”,”TextIcon”:”It amazes me”},
{“emocion”:”alegre”,”TextIcon”:”I am glad”}
]};
var options = $.extend({}, defaults, options);

$(ratethis).each(function( index ) {
var UnicoID = Date.now();
$(this).attr(“class”,$(ratethis).attr(“class”)+” “+UnicoID);
var FirstSelect=”alegre”;
if($(this).val()!=””){
FirstSelect=$(this).val();
}else{
$(this).val(‘alegre’);
}
icon_description=FirstSelect;
FirstElement=”;
FirstElement=FirstElement+'<div data_info=”‘+icon_description+'” ‘;
FirstElement=FirstElement+’ref_id=”‘+UnicoID;
FirstElement=FirstElement+'”  class=”‘+varSelect;
FirstElement=FirstElement+’ selectorFace ‘+FirstSelect+'”></div>’;
$(this).before(FirstElement);
});

$(document).ready(function() {
All_Icons='<div class=”ratethis”>’;
$.each(options.allicons, function(index,emo ){
All_Icons=All_Icons+'<div data_info=”‘+emo.TextIcon;
All_Icons=All_Icons+'” class=”‘+emo.emocion+'”></div>’;
});
All_Icons=All_Icons+'</div>’;
$(document.body).append(All_Icons);
$(‘.ratethis div’).hover(function(){
var title = $(this).attr(‘data_info’);
$(this).data(‘tipText’, title).removeAttr(‘data_info’);
$(‘<p class=”MessageText”></p>’).text(title).appendTo(‘body’).fadeIn(‘slow’);
},function() {
$(this).attr(‘data_info’, $(this).data(‘tipText’));
$(‘.MessageText’).remove();
}).mousemove(function(e) {
var RatonX = e.pageX – 20;var RatonY = e.pageY – 60;
$(‘.MessageText’).css({ top: RatonY, left: RatonX })
});
});
$( ‘.’+varSelect ).hover(function(e) {
SelectEmoticon= $(this);
var RatonX = e.pageX – 20;var RatonY = e.pageY – 60;
$( “.ratethis” ).css({ top: RatonY, left: RatonX });
$( “.ratethis” ).show();
$( “.ratethis div” ).click(function() {

SelectEmoticon.attr(“class”,varSelect+” selectorFace  “+$(this).attr(‘class’));

InputSelect=SelectEmoticon.attr(“ref_id”);
$(“.”+InputSelect).val($(this).attr(‘class’));

});
});
$(document).mouseup(function (e){  $( “.ratethis” ).hide();});
$(ratethis).hide();

}
});

You will need also one test.png image width / height = 48 x 384 with 8 emoticons.

All of this file and jquery-2.2.0.js will be into your folder project.

About how is made is one selection over icons with one id.

You will see also text for each emoticon and the result will be show on your project webpage.

rate
NOTE: This example is a fork for code by oscaruhp.
I make some changes to see how you can used.
You can see all project on this:

# FaceMocion
Demo:
http://oscaruhp.github.io/FaceMocion/

Posted in All, HTML 5, javascript, Programming. Tagged with , , , .

Simple shadow text with CSS with webkit-filter.

This simple example will put one shadow to the text.

The source code is simple and the goal come with filter and webkit-filter: drop-shadow.

<!DOCTYPE html>
<html>
<head>
<title>Exemple text shadow.</title>
<style>
.element{
width: 300px;
height: 300px;
float: left;
}

.element:hover{
-webkit-filter: drop-shadow(5px 5px 5px black);
filter: drop-shadow(5px 5px 5px black);
}
</style>
</head>
<body>

<div class=”element”>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer feugiat lectus placerat sem tincidunt consequat. Nullam euismod enim vel ante cursus accumsan. Fusce pulvinar rhoncus luctus.</div>
</body>
</html>

Posted in All, HTML 5, javascript, Programming. Tagged with , , , .

Flash example with jQuery.

Just created a box with colors and also put the text into it.

This example will flash your eyes but also you can used with any effects.

<!DOCTYPE html>
<html>
<head>
<title>Flash example</title>
<script src=”jquery-2.2.0.js”></script>
<style type=”text/css”>
#canvas_id {
position: fixed;
left: 0px;
top: 0px;
z-index: -10;
width: 100%;
height: 100%;
}
html, body {
margin: 0px;
}
#body {
margin: 8px;
}
</style>
</head>
<body>
<canvas id=”canvas_id”></canvas>
<div id=”body”>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean nec gravida est, nec fermentum metus. Suspendisse congue ante elit, vitae accumsan quam convallis nec. Integer sodales, nibh id ultricies hendrerit, risus lacus varius ligula, quis porta nulla massa sit amet quam. Praesent posuere vulputate nunc, ac convallis nulla consectetur eget. Vestibulum eu dapibus justo. Aenean ac venenatis sem. Nullam porta, augue at egestas pretium, diam metus suscipit eros, eu eleifend quam diam in lacus. Fusce accumsan sem in placerat blandit. Nulla eget hendrerit lorem, at semper leo. Duis non commodo tellus.
</p>
</div>
<script type=”text/javascript”>
var canvas = document.getElementById(“canvas_id”);
var gl = canvas.getContext(“experimental-webgl”);
var resize = function() {
var width = gl.canvas.clientWidth;
var height = gl.canvas.clientHeight;
if (gl.canvas.width != width || gl.canvas.height != height) {
gl.canvas.width = width;
gl.canvas.height = height;
console.log(“new size: ” + width + “, ” + height);
}
};
var render = function() {
resize();
gl.clearColor(1, Math.random() * 0.2 +0.5, 1, 1);
gl.clear(gl.COLOR_BUFFER_BIT);
requestAnimationFrame(render);
};
render();
</script>
</body>
</html>

Posted in All, HTML 5, javascript, Programming. Tagged with , , , .