Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

Which CSS will support in Email Clients- Outlook, Gmail, iPhone... ?

Which CSS will support in Email Clients ?

I have been developing html for sending email notification for my product. It was a head ache to make the alignment correct across all the devices. The page should be responsive. The html can be tested in litmus tool for checking alignment in different devices.

To know the css support in different email clients, https://www.campaignmonitor.com/css/ was very much helpful. It lists support of css in different email clients. 

AngularJS Prevent Event Propagation Click Example

AngularJS Prevent Event Propagation Click Example

Today I was stuck with a problem in angularjs. I have a table row and a button in table cell. I have bound event event for both table row and button. So I have to disable event on table row click when I click on button, in other words I have to stop propagation of event on button click.

I found a solution as below,

<a href="#" ng-click="functionName(); $event.preventDefault(); $event.stopPropagation();">


$event.stopPropagation(); alone was not working. When I used $event.stopPropagation(); alone, on click it was redirecting to some other page. When I tried adding  $event.preventDefault(); $event.stopPropagation();. It worked.

Reference:
http://stackoverflow.com/questions/10931315/how-to-preventdefault-on-anchor-tags

CORS (Cross Origin Resource Sharing) and Disabling Web Security

CORS (Cross Origin Request Policy) and Disabling Web Security



You might have come to this error XMLHttpRequest cannot load xxx.com/xxx/... No 'Access-Control-Allow-Origin' header is present on the requested resource.Origin abc.com is therefore not allowed to access. Here abc.com want to access resources of xxx.com, but browser is telling it is not allowed to access the resource since 'Access-Control-Allow-Origin' header is not present. This is due to cross origin resource sharing(CORS) policy.

According to w3c specification, cross domain communication is possible. That is abc.com can access the resources of xxx.com provided xxx.com should allow others to access its resources. Xxx.com can allow others to access its resources by setting 'Access-Control-Allow-Origin' to its response header. If it is not set, then the resources can not be accessed from other domains. Usually 'Access-Control-Allow-Origin' is set for public data.

If you are a web developer, you might have faced this above issue. For Google chrome, you will get some relax by disabling web security. That is you can still access the data from other domain even if  'Access-Control-Allow-Origin' is not set by disabling web security in chrome browser.

To disable web security, make a shortcut for chrome on desktop, and in the shortcut properties add the parameter --disable-web-security at the end of chrome executable path.

"C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-web-security

Close all chrome windows/tabs and start Chrome using this shortcut icon. If web security is disabled, you will  see the yellow bar below the address bar with the warning message.

Number Formatting in JavaScript using toLocaleString - Thousand Separator, Currency Formatter

Number Formatting in JavaScript using toLocaleString() - Thousand Separator, Currency Formatter

Today I came across toLocaleString() in javascript which can be used for formatting numbers. Thousand separator, currency formatting etc. can be achieved using this.

var num1= 2000;
num1.toLocaleString();  // "2,000"

 Thousand separator is different for different countries. This is also possible using toLocaleString().

num1.toLocaleString("en-US");
"2,000"
num1.toLocaleString("de-DE");
"2.000"
num1.toLocaleString("ar-EG");
"٢٬٠٠٠"

Currency formatting can also be done.

num1.toLocaleString('ja-JP', { style: 'currency', currency: 'INR' })

"Rs.2,000"

https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString

The Responsive jQuery Content Slider

The Responsive jQuery Content Slider

Came to know about a slider.The Responsive jQuery Content Slider. It is responsive. The content can be images, videos or HTML content.

License : The MIT License (MIT)

more info : http://bxslider.com/

Height and Span

Can we set height to span?

Can we set height to span? The answer is no. Span is an inline element. If you provide height to span, there will not be any effect. If you really want to set height then you will have to add  display : inline-block or display : block.

SVG.js manipulating and animating SVG - Clock using svg





SVG.js

Came across a beautiful clock example using svg which is developed using plugin SVG.js which is used as lightweight library for manipulating and animating SVG.

http://jsfiddle.net/boser18/7qcn3ptr/



Responsive Website Using Bootstrap

Simple Responsive Website Using Bootstrap



Just found good tutorial to develop a responsive website using Bootstrap. Just add bootstrap libraries amd use some class names for div elements from css and the website will automatically resize with the change in resolution which makes your website accessible via mobile devices as well as desktop browsers.

Libraries:  bootstrap.css, bootstrap-responsive.css, bootstrap.js,  jquery.min.js.

Class names: container, row-fluid, span1,span2,...,span12,offset1,...

Just follow the Template:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-width=1.0">

<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap-responsive.css">

</head>
<body>
<div class="container">
<div class="row-fluid">
<div class="span6">
...content
</div>
</div>
</div>

<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.js"></script>
</body>
</html>

Try this small Example:

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-width=1.0">

<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/bootstrap-responsive.css">

</head>
<body>
<div class="container">
<div class="row-fluid">
<div class="span6">
<p>A man who was completely innocent, offered himself as a sacrifice for the good of others, including his enemies, and became the ransom of the world. It was a perfect act. - <b>Mahatma Gandhi</b></p>

</div>
<div class="span6">
<p>Take up one idea. Make that one idea your life - think of it, dream of it, live on that idea. Let the brain, muscles, nerves, every part of your body, be full of that idea, and just leave every other idea alone. This is the way to success. -<b>Swami Vivekananda</b></p>
</div>
</div>
</div>


<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.js"></script>
</body>
</html>


Draw Triangle or Arrow Using DIV ::after CSS HTML

Draw Triangle or Arrow Using DIV ::after CSS HTML



Suppose we want to add an arrow to bottom of div or any other element, just add the css below.


#divid::after{
position:absolute;
border-top:25px solid #f00;
border-left:25px solid transparent;
border-right:25px solid transparent;
border-bottom:25px solid transparent;
content:'';
display:inline-block;
border-right-width:25px;
top:50px;
left:25px;
box-sizing:border-box;
}



example:


<!DOCTYPE html>
<html lang="en">
<head>
<style>

#id1::after{
position:absolute;
border-top:25px solid #f00;
border-left:25px solid transparent;
border-right:25px solid transparent;
border-bottom:25px solid transparent;
content:'';
display:inline-block;
border-right-width:25px;
top:50px;
left:25px;
box-sizing:border-box;
}
</style>
</head>
<body>
<div id="id1"></div>
</body>
</html>


Demo: