CSS :before and :after Pseudo-element

The before and after insert content before and after of the element .

Let’s see an example below.

Here is HTML:

<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc adipiscing tristique dictum. Nunc odio sapien, sagittis a viverra non, consequat sed urna. Nunc blandit mi nisl, ut condimentum mi iaculis ut. Morbi eget ante luctus, venenatis augue sed, condimentum tortor. Aliquam pretium commodo enim, vel consequat lacus dignissim quis. Vivamus tristique luctus egestas. Mauris aliquam enim et velit rhoncus, a tempus neque faucibus. Pellentesque nec erat ut nunc ultrices suscipit eget ac metus. Suspendisse eget auctor eros, ut dignissim ante. Nunc non justo facilisis odio blandit euismod non nec metus. Quisque eu felis nisl. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam tempus consectetur lorem vitae facilisis.
</p>

And here is CSS

p:before
{
    content:"'";
    font-weight:bold;
}
 p:after
{
    content:"'";
    font-weight:bold;
}

In the above css we have applied: before and :after on the p element. We have set content to single quote and weight of the font is set to bold.

Here how the p element will render to browser.

beforeandafter

You will see the single quote appears before and after the content of the p element.

You can see live example here http://jsfiddle.net/mandarBadve/3ye7E/

Enrich user interface of your web application with Bootstrap UI framework

Bootstrap is very reach UI framework, flexible and responsive. It is made by Twitter and hosted on github.

You can find the more details at http://getbootstrap.com/

Let’s start to integrate this framework into your web application.

Very first you need to download framework files from bootstrap website mentioned above. Download will contain ZIP file (bootstrap-x.x.x-dist.ZIP)

After extracting the downloaded ZIP file, you will get three folders:

  • css: This folder contains style sheets files for the bootstrap framework and theme
  • fonts: This folder contains necessary files for the fonts
  • js: This folder contains JavaScript files for bootstrap framework.

For the further process I have used Visual Studio to create and manage web application. You can use any editor instead of the Visual Studio.

In the Visual Studio go to the menu:  File -> New -> Project. It opens New Project dialog. Select ASP.NET Web Application and give the name for the solution.

Enrich user interface of your web application with Bootstrap UI frameworkClick on OK then Select Empty project type.

select empty project template

Click OK to create project.

You will see solution created as below.

Solution1

Right click on ‘WebAppWithBootstrap’ the solution select Add then select HTML Page.

Solution2Give the name as index.html

Solution3

Index.html file is created opened in editor.

Now add folder ‘Bootstrap’ by right-click on solution and choose Add and then New Folder.

Solution4

Then create two folder called ‘css’ and ‘js’ inside the folder ‘Bootstrap’

Solution5

Now copy the ‘bootstrap.min.css’ file from css file folder of the extracted Bootstrap zip file to the css folder of the solution. Also copy the ‘bootstrap.min.js’ JavaScript file from js folder of the extracted Bootstrap zip file to the js folder of the solution.

Solution6

Now we need to give references of the added css and js file into index.html file as follows.

Solution7

Here we have added meta tag with viewport and set content width=device-width. This made your page responsive.

We have done with the integration of Bootstrap framework with web application.

Now open the page into browser.

Solution8

jQuery Mobile Introduction

Touch-Optimized Web Framework for Smartphones & Tablets

Recently I worked on mobile application based on HTML5 and JQuery. I have used jQuery mobile framework. It is very simple to learn and use, if you already know jQuery. You can find out more stuff from below site.

http://jquerymobile.com/

You can view documentation from below site. This site optimized to open in all mobile browsers.

http://demos.jquerymobile.com/1.4.0/

You can download necessary files to use jQuery mobile from below site.

http://jquerymobile.com/download/

jQuery mobile also provide CDN-hosted versions. These are minified and compressed with host images.

You need to copy and paste following lines into your project to use jQuery mobile framework.

<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>

jQuery mobile supports theme based UI. This framework also provides default themes. You can create your own custom theme by theme roller.

http://themeroller.jquerymobile.com/

Metro style context menu using JavaScript and CSS

What is context menu?

When you right click on browser window, browser will show you a menu containing some common functions.
See following image for reference.

Metro style context menu using JavaScript and CSS

If you want to build your own custom context menu, follow the easy steps below.

Step 1 – HTML

<div id="context-menu">
<ol>
<li><a href="#">menu 1</a> </li>
<li><a href="#">menu 2</a> </li>
<li class="list-devider">
<hr />
</li>
<li><a href="#">menu 3</a> </li>
<li><a href="#">menu 4</a> </li>
<li><a href="#">menu 5</a> </li>
<li class="list-devider">
<hr />
</li>
<li><a href="#">menu 6</a> </li>
<li><a href="#">menu 7</a> </li>
</ol>
</div>

Step 2 – CSS

Following is CSS declaration for above context menu structure. This will give metro style look to context menu.

#context-menu
{
z-index: 1000;
position: absolute;
border: solid 2px black;
background-color: white;
padding: 5px 0;
display: none;
} #
context-menu ol
{
padding: 0;
margin: 0;
list-style-type: none;
min-width: 130px;
width: auto;
max-width: 200px;
}
#context-menu ol li
{
margin: 0;
display: block;
list-style: none;
zoom: 0;
padding: 5px 5px;
}
#context-menu ol li:hover
{
background-color: #efefef;
}
#context-menu ol li:active
{
color: White;
background-color: #000;
}
#context-menu ol .list-devider
{
padding: 0px;
margin: 0px;
}
#context-menu ol .list-devider:hover
{
/*background-color: #efefef;*/
}
#context-menu ol .list-devider hr
{
margin: 2px 0px;
}
#context-menu ol li a
{
color: Black;
text-decoration: none;
display: block;
padding: 0px 5px;
}
#context-menu ol li a:active
{
color: White;
}

Step 3 – JavaScript

To enable context menu, write down following script.

$(document).ready(function () {
try {
$(document).bind("contextmenu", function (e) {
e.preventDefault();
$("#context-menu").css({ top: e.pageY + "px", left: e.pageX + "px" }).show(100);
});
}
catch (err) {
alert(err);
}
});

Note: Above script require JQuery to be included in document.

In above script we have set context menu function to our custom function. This function will prevent default context menu of browser and
will show custom context menu.

Here we can add following function when user clicks on document, will hide context menu.

$(document).bind("click", function (event) {
$("#context-menu").hide();
});

look at the beautiful metro style context menu tested in IE9.

Metro style context menu using JavaScript and CSS

Enjoy JavaScript…

Fixed width, centered design in SharePoint site using css

By default SharePoint gives 100% width to sites created. We can fixed width of site by using custom css and changing some class names
in master page.

Lets have look to the solution.

div.s4-title.s4-lp, body #s4-mainarea, #s4-topheader2, #s4-statusbarcontainer
{
width: 960px;
margin: auto;
padding: 0px;
float: none;
background-image: none;
background-color: white;
}

To get fixed width design add css classes to the following element.

Default

<div id="s4-workspace">

Fixed Width

<div id="s4-workspace">

Default

<div id="s4-titlerow" class="s4-pr s4-notdlg s4-titlerowhidetitle">

Fixed Width

<div id="s4-titlerow"  class="s4-pr s4-notdlg s4-titlerowhidetitle s4-nosetwidth">

Fixed width, centered design in SharePoint site using css