Wednesday, 28 January 2015

CSS Animation: Let's Rotate Something

CSS Animation: Let's Rotate Something
T
I
T
L
E
Reload the page to invoke the animation again
Jazz up your website with a bit of animation!

If you use the CSS animation property it's super easy to create some eye-catching effects. In the example above, the boxes rotate to the right side within a certain time.

For each alphabet create a div element and put a unique id on it. The CSS animation property defines the duration of the animation:

animation:
[name of the animation]
[duration in seconds s] [timing] [frequency] [how the animation should be played][effect of the animation on the element after the animation]
.

You need to put the prefix -webkit- in front of animation in order to display it in all browsers.

After you have decided the duration of the animation you need to set the details of it. What kind of changes do you want to apply on the element? Does the color, width or size etc. change? @keyframes enables you to make the change. In the example above, I want to change the angle of the div boxes from 315 to 360 degrees. Here are the details of the syntax:
@keyframe rotate45(name of animation){
from{ transform:rotate(315deg);}
to{ transform:rotate(360deg);}
}
And finito!

HTML and CSS Code

Thursday, 22 January 2015

Glowing Tabs With CSS Hover And Transition

Glowing Tabs With CSS Hover
  • Top
  • About
  • Privacy
Let's spice up a website with more blinky blinky effects.

I thought, tabs which will glow like neon signs when you rollover with your mouse on them would look fantastic. You even don't need JavaScript just CSS!

Hover selector and transition property are the magical words to make things happen. After finishing writing the code for the tabs make them look nice with CSS (#tabs). To add a glowing effect to the tabs we want to change the shadow. The CSS property box-shadow allows us to change the color and shadow of a box. Here is the code: box-shadow:[x-coordinate] [y-coordinate] [blur] [color]; . By assigning the hover (:hover) selector to the tab class (.tabs) it will create the rollover effect.

.tabs:hover describes how the property box-shadow should change. Property details, duration and timing of the effect is set by transition. Don't forget to make that property browser friendly to all browsers and the prefixes -o-, -webkit-, -moz- and -ms- to transition.
Since we want to change all box-shadow properties use "all" to change them all.
Hover is both a blessing and a curse- it's not really Android and iPhone compatible. I will work on this issue!

HTML, CSS and JavaScript Code all in one

Tuesday, 20 January 2015

Star With CSS

Star With CSS

all cover rectangles displayed in different colors

It's time to create a star with CSS!

The first step is to create a huge square which has the tag div and the id="body27". Using invisible cover rectangles colored in white and with different degrees on the left and right site of this square forms the star shape.

A picture says more than thousand words-I've put different colors on the cover rectangles to make it crystal clear how the object is created so please have a look at the code below.

HTML and CSS Code

Monday, 19 January 2015

How To Filter Certain Characters with JavaScript RegExp

Nice to meet you! What's your name?



Jean the Pig wants to greet you!
If you type in your name and push the button a greeting message from Jean the Pig will appear below the text field. To filter certain characters I've used the metacharacter \w of the RegExp object. \w means that you can only type in word characters like alphabets or numbers. /\^w{1,10}$/g means that it has to begin (^) and end ($) with a word character (\w) and should be no longer than 10 characters ({1,10}). The modifier g means it'll do a global match on the text which was typed in inside the text field.

Now, how do we get the text inside the text field? The value attribute of the input tag, input type="text" value="", describes the text which was typed in by the user. To get the use input use document.getElementById("inputtext").value in JavaScript. To exclude non-word character inputs I've used the match() method just matching \w characters.

For details, have a look at the code!

HTML, CSS and JavaScript Code

Tuesday, 13 January 2015

Stylish Blue Tabs with CSS and JavaScript

  • Top
  • About
  • Privacy Policy

A stylish website needs stylish tabs. Here are some design ideas for tabs. If you rollover the tabs with your mouse pointer they will protrude.

The mouse events onmouseenter and onmouseleave of JavaScript creates this effect.First of all, get the info of each tab with document.getElementById("id") and assign a variable to it. Then assing a mouse event to each variable. In the example, the tabs should protrude if the mouse enters them and return to their initial state if the mouse leaves the tabs which is done with onmouseenter and onmouseleave.
So, what kind of event would you like to create? In my event, the CSS text-shadow and box-shadow property should change therefore I have written the following function: function (){variable.style.textShadow xp xp xp color; variable.style.boxShadow xp xp xp color;}.
Very important: insert the script inside the HTML body elment because if you put it inside the head element nothing will fire.

I will create more stylish tabs.



HTML, CSS and JavaScript Code all in one

Monday, 12 January 2015

Pixel Bunny: Growing and Shrinking Objects with Offset and Client

Pixel Bunny

Grow or shrink the bunny!

The code does not work within this blog so please save the code on your desktop and try it out.
I was mindlessly doodling around on a Sunday afternoon when I had the idea to make a bunny with CSS and grow and shrink it with JavaScript.

The whole bunny is designed just with CSS. I won't go into details so please have a looksee at the code below.

I thought, I want to grow and shrink that little bunny. Yes, sounds like we need JavaScript. Growing and shrinking the body of the bunny means in other words adding pixels to it.

A perfect object for that are the 2 event objects offsetX and clientX. ClientX outputs the x-coordinate of the mouse pointer on the screen. For example, if you put the mouse on the top left corner of the browser the coordinate will be x = 0. OffsetX returns the x-coordinate of the div element.

Since it is an event object you have to write "event" inside the expression of the function otherwise nothing will fire. In the example it is "change(event)". The event is triggered when the move is moved horizontally.







HTML, CSS and JavaScript Code

The code below has to be saved as a .html file!