Showing posts with label css. Show all posts
Showing posts with label css. Show all posts

Wednesday, November 27, 2013

Using jshybugger to debug HTML, CSS and javascript on native Android browser


Debugging web applications on android device as been a challenging issue. This becomes further challenging when the debugging is to be done on native browser of Android.
The debugging tools provided by native android browser are insufficient to perform detailed analysis of the problem. (In case you're not aware about these tools and wish to check em out type "about:debug" in your native browser's address bar and then check your settings menu for debug options).
While looking for solution of one of my problems on native android browser i came across this tool which does the job brilliantly! Its name is jsHybugger (https://www.jshybugger.com/#!/).

When you use jsHybugger App, jsHybugger runs on your device and provides two things:
  • a proxy between the native Android browser and the web server where your mobile web pages are hosted
  • a communication endpoint for the debugging frontend on your development machine
Using this very simple and straight forward. Steps for it are as follow:

  1. Download and install the APK file for jsHybugger App, either through a direct download on your device or from your development machine using ADB.
  2. Start jsHybugger App on your device and adjust the configuration (see parameters below).
  3. Open the native Android browser via Open browser. The browser automatically navigates to the specified URL.
  4. Connect to jsHybugger.
  5. Set port forwarding to enabled in ADB interface. For more information on how to use ADB extension please refer to my earlier blog post (http://anirudhprabhu.blogspot.in/2013/08/debugging-website-or-web-application.html)

Parameters
  • Remote host: IP address or hostname of the remote web server
  • Remote port: HTTP port of the remote web server (usually 80)
  • URI: URI of the start page, e.g. /index.html
Control
  • Stop service: Stop service on device
  • Start service: Start service on device
  • Open browser: Start the Android browser with the configured URL
  • Clear cache: Clear jsHybugger cache
  • Log viewer: Display HTTP access log

Happy Debugging!!!

Saturday, April 27, 2013

Introduction to SASS

In this blog post i will be giving you a short tutorial on SASS that will clear most of the fundamental syntax and how the language work.
Sass is an extension of CSS3, adding nested rulesvariablesmixins,selector inheritance, and more. It’s translated to well-formatted, standard CSS using the command line tool or a web-framework plugin.
You can see how to install SASS here: http://sass-lang.com/

FUNDAMENTALS:

1.
 Declaring variables in SASS: You declare variables in SASS using following notation :: 


$blue: #00F;

This can be used in you scss file as follows:

color: $blue;

2. Declaring list in SASS: You declare list in SASS using following notations ::

$icons: twitter facebook youtube.

List comes handy when you want generate a set of element in some common fashion. For example you might wish to generate a series of divs with different background images and having same dimensions. You can do that in following manner:

@each $social in $icon{
##{$social}{background: image-url("avatars/#{$social}.png") no-repeat}
}

MIXINS:

Mixin is a way by which you can declare a reusable chunk of code. This can also be called as advanced version of variable.
Example:


@mixin border-radius($radius:10px){
border-radius: $radius;
-moz-border-radius: $radius;
-webkit-border-radius: $radius;
-o-border-radius: $radius;
}

These mixins can be used in your code in following manner:

@include border-radius(5px)

SELECTOR INHERITANCE:

In SASS, you can inherit styles from one class into another class. This can be done in following manner:

.primaryClass{
/*Style declaration*/
}

.secondary{
@extend .primaryClass;
}

This feature can come handy when you want to reuse certain style attributes across multiple classes like fonts, color.

@IMPORT

Sass extends the CSS @import rule to allow it to import SCSS and Sass files. All imported SCSS and Sass files will be merged together into a single CSS output file. In addition, any variables or mixins defined in imported files can be used in the main file.

Example:

@import "reset";

NESTING SELECTORS

Sass avoids repetition by nesting selectors within one another. The same thing works with properties.

Example for this:


.nav{
background-color: $brandcolor;
width:100%;
height: 64px;
@include setMargin("10px","20px","30px","40px");
.container{
.items{
position: relative;
.submenu{
width:96px;
@include border-radius(5px)
}
}
}
}

When compiled this will output:

.nav {
  background-color: #ac2428;
  width: 100%;
  height: 64px;
  margin: 10px 20px 30px 40px;
 }
.nav .container .items {
  position: relative;
}
    
.nav .container .items .submenu {
      width: 96px;
      border-radius: 5px;
      -moz-border-radius: 5px;
      -webkit-border-radius: 5px;
      -o-border-radius: 5px; 
}

USING LISTS AND @each

We can process a list to get some meaningful styles. Here is an example where i m creating social classes based on the list of social names that have been provided in the list.

$icon:twitter facebook youtube;
@each $social in $icon{
##{$social}{background: image-url("avatars/#{$social}.png") no-repeat}
}

BUILD YOUR OWN FUNCTION

It is possible to define your own functions in sass and use them in any value or script context.


@function grid-width($n) {
  @return $n * $grid-width + ($n - 1) * $gutter-width;
}

#sidebar { width: grid-width(5); }

LOOPING IN SASS USING FOR LOOP

We have provision in SASS where we can loop using for loop. Example of this:

$class-slug: for;
@for $i from 1 through 4{
.#{$class-slug}-#{$i}{
@if $i > 2{
width:60px;
}
@else{
width:40px;
}
}
}

As you can see in this example we are generating four classes using for loop. Within this loop we see the number of iteration and assign the width accordingly. This also shows implementation of if.

GENERATING CSS SHORTHANDS USING SASS

While working on SASS when writing this tutorials i cam across a scenario where i wanted to write a mixin that would throw me shorthand declaration instead of providing me separate declarations.
For example how would you generate a something like

margin: 10px 20px 30px 40px;

using SASS? Here's how you do it:


@mixin setMargin($top,$right,$bottom,$left){
margin: #{$top} #{$right} #{$bottom} #{$left};
}

You can use this mixin in following manner

@include setMargin("10px","20px","30px","40px");

Well this is it for fundamentals of SASS. You can also refer to this manual for trying out more stuff in SASS:
http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html

Yet another good site for reference is:
http://thesassway.com/

For any queries feel free to write to : prabhu.anirudh@live.in


Thursday, February 16, 2012

Crunch: The LESS editor and Compiler

A good air app for using less css on windows! Finally we can use less on windows machine without any installation hassles.

Crunch: The LESS editor and Compiler

Crunch it and you're good to go!

Sunday, February 20, 2011

Small issue of padding difference observed between chrome and firefox

In some elments like heading (h1,h2,h3,h4 etc) and anchors elements show weird padding difference. For example element that appears aligned properly in firefox may appear aligned slightly above or below its position in chrome.

This problem exist even after applying css reset. After trying out few things i found solution to this problem. All you need to do is add this line to the beggining of the css.

*{margin:0,padding:0}

And the issue is sorted. :)

Friday, July 16, 2010

Resizing Background to fit in any screen resolution without repeats

Ever wondered how to use actually picture like a photo or something in your background without worrying about how it will be rendered in various resolutions?
Here is a solution for the issue. It is possible using Jquery and CSS. The logic for this task is very simple: Detect the browser window width and height and assign those values to the background image.
Now here points to keep in mind are that the background image is not to be specified in CSS. For this task create a div with lowest z-index value and place your background image inside it using img tag. Also assign it an id.
You can detect browser width and height using jquery's width and height function as follows:
$(window).width()

Store these values in a variable and again use the same width and height functions to assign those value to the image. For that just replace the window in earlier example with reference to your background.
Have a nice day :)