Bootstrap a sample blog post details/read more page

Reading Time: 2 minutes

[code]

<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”utf-8″>
<meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>

<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css” integrity=”sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp” crossorigin=”anonymous”>
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css” integrity=”sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u” crossorigin=”anonymous”>

<style type=”text/css”>
body {
background: #eee !important;

}
.page-header{
margin-top: 0 !important;
}
.panel-body{
padding-top: 0;
}
.featuredImg{
margin-bottom: 15px;
}
</style>
<!– HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries –>
<!– WARNING: Respond.js doesn’t work if you view the page via file:// –>
<!–[if lt IE 9]>
<script src=”https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js”></script>
<script src=”https://oss.maxcdn.com/respond/1.4.2/respond.min.js”></script>
<![endif]–>
</head>
<body>

<div class=”container”>
<div class=”row”>
<div class=”col-lg-9″>
<div class=”panel panel-default”>
<div class=”panel-body”>
<div class=”page-header”>
<h3>Page Header Section</h3>
</div>
<img class=”featuredImg” src=”https://cnet3.cbsistatic.com/img/syklRsrXJcU4HS4I9FxtIikHa-k=/770×433/2014/10/13/0ea985b4-9f3a-43d0-9a47-21154c864996/samsung-galaxy-note-4-9024.jpg” width=”100%”>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>

<h4>Another heading</h4>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
</div>
</div>
</div>
</div>

<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js”></script>
<script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js” integrity=”sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa” crossorigin=”anonymous”></script>
</body>
</html>

[/code]

Aligning 2 div elements side by side

Reading Time: 2 minutes

css file

[code]

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

.clearfix:after{
content: “”;
display: table;
clear: both;
}

body {
font-size: 18px;
font-family: Helvetica Neue, Arial;
}

h1,
h2 {
color: #019801;
}

h1 {
font-size: 40px;
margin-bottom: 20px;
}

h2 {
font-size: 25px;
margin-bottom: 10px;
}

.main-text {
text-align: justify;
margin-bottom: 20px;
}

#author-text {
font-size: 22px;
}

.container {
width: 1140px;
margin-left: auto;
margin-right: auto;
}

.blog-post{
background-color: #000ff0;
width: 75%;
float: left;
}

.other-posts{
background-color: #00ff00;
width: 25%;
float: left;
}

.author-box{
background-color: #ffff00;
}

[/code]

html file

[code]

<div class=”container”>
<div class=”blog-post”>
<h1>My first blog post</h1>
<h2>This is my first blog post</h2>
<p class=”main-text”>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>

<img src=”logo.jpg” alt=”This is HTML5 logo”>

<a href=”http://www.udemy.com” target=”_blank”>Link to Udemy</a>
<a href=”logo.jpg” target=”_blank”>HTML logo</a>

<h2>HTML is amazing</h2>

<p class=”main-text”>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>

<div class=”other-posts”>
Dummy text
</div>
<div class=”clearfix”></div>
<div class=”author-box”>
<img src=”author.jpg” alt=”Author Photo”>
<p class=”main-text”> Florence Smith</p>
</div>
</div>

[/code]

Bootstrap Article Details/Read more page with the tab of other articles

Reading Time: 2 minutes

[code]

<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”utf-8″>
<meta http-equiv=”X-UA-Compatible” content=”IE=edge”>
<meta name=”viewport” content=”width=device-width, initial-scale=1″>

<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css” integrity=”sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp” crossorigin=”anonymous”>
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css” integrity=”sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u” crossorigin=”anonymous”>

<style type=”text/css”>
body {
background: #eee !important;

}
.page-header{
margin-top: 0 !important;
}
.panel-body{
padding-top: 0;
}
.featuredImg{
margin-bottom: 15px;
}
</style>
<!– HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries –>
<!– WARNING: Respond.js doesn’t work if you view the page via file:// –>
<!–[if lt IE 9]>
<script src=”https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js”></script>
<script src=”https://oss.maxcdn.com/respond/1.4.2/respond.min.js”></script>
<![endif]–>
</head>
<body>

<div class=”container”>
<div class=”row”>
<div class=”col-lg-9″>
<div class=”panel panel-default”>
<div class=”panel-body”>
<div class=”page-header”>
<h3>Page Header Section</h3>
</div>
<img class=”featuredImg” src=”https://cnet3.cbsistatic.com/img/syklRsrXJcU4HS4I9FxtIikHa-k=/770×433/2014/10/13/0ea985b4-9f3a-43d0-9a47-21154c864996/samsung-galaxy-note-4-9024.jpg” width=”100%”>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>

<h4>Another heading</h4>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>
</div>
</div>
</div>
<div class=”col-lg-3″>
<div class=”list-group”>
<a href=”#” class=”list-group-item active”>
<h4 class=”list-group-item-heading”>Article 1</h4>
<p class=”list-group-item-text”>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium</p>
</a>
<a href=”#” class=”list-group-item”>
<h4 class=”list-group-item-heading”>Article 2</h4>
<p class=”list-group-item-text”>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium</p>
</a>
<a href=”#” class=”list-group-item”>
<h4 class=”list-group-item-heading”>Article 3</h4>
<p class=”list-group-item-text”>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium</p>
</a>
<a href=”#” class=”list-group-item”>
<h4 class=”list-group-item-heading”>Article 4</h4>
<p class=”list-group-item-text”>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium</p>
</a>
</div>
</div>
</div>
</div>
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js”></script>
<script src=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js” integrity=”sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa” crossorigin=”anonymous”></script>
</body>
</html>

[/code]

Bootstrap Grid System

Reading Time: 3 minutes

col-md-3

col-xs-9

The available grids: http://getbootstrap.com/css/#grid-options

Example Code

[code]

<!– MAIN CONTAINER BEGIN –>
<div class=”container”>
<div class=”row”>
<div class=”col-md-3″>
<h3>Article 1</h3>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class=”col-md-3″>
<h3>Article 2</h3>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
</div>
<div class=”col-md-3″>
<h3>Article 3</h3>
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
</div>
<div class=”col-md-3″>
<h3>Article 1</h3>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</div>
<div class=”col-md-3″>
<h3>Article 2</h3>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?
</div>
<div class=”col-md-3″>
<h3>Article 3</h3>
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
</div>
</div>
</div>
<!– MAIN CONTAINER END –>

[/code]

Bootstrap navigationbar

Reading Time: 1 minute

[code]

<div class=”navbar navbar-inverse navbar-static-top”>
<div class=”container”>
<div class=”navbar-header”>
<button type=”button” class=”navbar-toggle” data-toggle=”collapse” data-target=”.navbar-collapse”>
<span class=”icon-bar”> </span>
<span class=”icon-bar”> </span>
<span class=”icon-bar”> </span>
</button>
<a href=”#” class=”navbar-brand”>Navbar Title</a>
</div>
<div class=”navbar-collapse collapse”>
<ul class=”nav navbar-nav navbar-right”>
<li class=”active”><a href=”#header”>Home</a></li>
<li><a href=”#”>Link 1</a></li>
<li class=”dropdown”>
<a href=”#” class=”dropdown-toggle” data-toggle=”dropdown”>Social Media <b class=”caret”></b></a>
<ul class=”dropdown-menu”>
<li><a href=”#”>Linkedin</a></li>
<li><a href=”#”>Facebook</a></li>
<li><a href=”#”>Instagram</a></li>
</ul>
</li>
<li><a href=”#login”>Log in</a></li>
</ul>
</div>
</div>
</div>

[/code]

Javascript Useful Resources

Reading Time: 1 minute

Finding out whether the browser is Google Chrome

[javascript]

isChrome = /Chrome/.test(navigator.userAgent) &amp;&amp; /Google Inc/.test(navigator.vendor);

[/javascript]

Getting element by class name and changing styles

[javascript]

var arr = document.getElementsByClassName(“ui-datepicker-trigger”);
var arrLength = arr.length
for (i = 0; i < arrLength; i++) {
arr[i].textContent=” “;
arr[i].style.height=”15px”;
arr[i].style.padding=”4px”;
}

[/javascript]

Getting element by id and appending style’s border-collapse

[javascript]

document.getElementById(“table-0”).style.borderCollapse = “collapse”;

[/javascript]

Iterating through children elements

[javascript]

var resultTable = document.getElementById(“table-0”).children;
for(i = 0; i < resultTable.length; i++){
console.log(resultTable[i]);
}

[/javascript]

Get element’s kind&tagname

[javascript]

document.getElementById(“element”).tagName

[/javascript]

String lower case

[javascript]

var strVal = “My Value”;

str lowerVal = strVal.toLowerCase();

[/javascript]