Skip to main content

CSS3 My Favorite Tricks

CSS3 is cool. It's animation and 3D stuff are amazing. But things like rounded corner and gradients are the most useful. I am listing down few tricks that I use often for my own quick reference.

Gradient


No more slicing.. and repeating images to make shaded backgrounds.

background-image: -webkit-gradient(linear, left top, left bottom, from(#6f6f6f), to(#000000)); /* mozilla - FF3.6+ */
background-image: -moz-linear-gradient(top, #6f6f6f 0%, #000000 100%); /* IE 5.5 - 7 */
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#6f6f6f',EndColorStr='#000000'); /* IE8 */
-ms-filter: progid: DXImageTransform . Microsoft . gradient(gradientType = 0, startColor = '#CCCCCC', endColoStr = '#000000'); /*Transparent back */


Shadows. Rounded Corner, and Transparent Layers.


I like to give a div a transparent background and put some kind of a background image under it. Drop the shadow from that box make it look much nice..


/*Transparent back */
opacity:0.4;

/*Rounded corners */
-moz-border-radius: 3px;
border-radius: 3px;
border: solid 1px #888888;

/*The shadow */
-moz-box-shadow: 3px 3px 2px #ddd;
-webkit-box-shadow: 3px 3px 2px #ddd;
box-shadow: 3px 3px 2px #ddd;


Styling a table with CSS3


Interesting thing to note here is the table.tableStyle tr:nth-child(even) selector. This is to color two rows with different colors, which we had to write javascript earlier.

table, td, div, span, a {
font-family: "Trebuchet MS", Verdana, Helvetica, Arial, sans-serif;
font-size: 12px;
}

table.tableStyle {
border-left: solid 1px #468aa6;
border-top: solid 1px #468aa6;
border-collapse: collapse;
}

table.tableStyle th {
background-image: -webkit-gradient(linear, left top, left bottom, from(#56aed2), to(#417f98));
background-image: -moz-linear-gradient(top, #56aed2 0%, #417f98 100%);
filter: progid:DXImageTransform.Microsoft.gradient(gradientType = 0, startColor = 0, endColorStr = #417f98);
-ms-filter: progid:DXImageTransform.Microsoft.gradient(gradientType = 0, startColor = 0, endColoStr = #417f98);
color: #fff;
font-size: 11px;
text-align: left;
padding: 3px;

border-right: solid 1px #468aa6;
border-bottom: solid 1px #468aa6;
}

table.tableStyle td {
border-right: solid 1px #468aa6;
border-bottom: solid 1px #468aa6;
margin: 0px;
padding: 3px;
}
table.tableStyle tr:nth-child(even) {background: #ccdde1}
table.tableStyle tr:nth-child(odd) {background: #FFF}

Comments

Popular posts from this blog

Projecting HTML Elements on a circle using Javascript

Recently I wonted to create a tree control with a different approach. The requirement was to represent a node tree with main node on the circle center and it's child nodes projected on a circle around it. This is what i wanted. My solution has 5 files prototype.js This is a handy javascript framework. You can download the latest version from there website ( www.prototypejs.org/download ). I am using this to simply handle the onload event in the page. circle.html script.js node-main-left.gif node-sub-left.gif The circle.html, prototype.js and the script.js files are in the root folder and the two images are inside a folder named “images”. This is how the html file looks(circle.html). <html> <head> <script src="prototype.js" type="text/javascript"></script> <script src="script.js" type="text/javascript"></script> <script language="javascript" xml:space...

Simple client side validation library

  Client side validation has never been easy.. Include jQuery and the validator.js < script src = " http://code.jquery.com/jquery-1.11.3.min.js " ></ script > < script src = " ../validate.js " ></ script > Simple validation < form id = " myForm " > < label >User Name < span class = " red-star " >*</ span > </ label > < input type = " text " name = " userName " class = " validate-required " /> < br /> < label >Password < span class = " red-star " >*</ span ></ label > < input type = " password " name = " password " class = " validate-required " /> < br /> < input type = " submit " value = " Login " /> </ form > ...

Overriding default look and feel of GREG - 5.3.0

Following list explains what are the best approach for different use cases. 1 ) - You created a new asset type, and you need to change the look and feel of the details page in the listing page just for that new asset type. To create a new asset type you need to login to the carbon console (username:admin, password:admin) https:// :9443/carbon/ Navigate to Extensions > Configure > Artifacts Click "Add new Artifact" link at the bottom of the page. By default in the "Generic Artifact" area "application" asset type is loaded. Note the shortName="applications" in the root node. "applications" is the name of the asset type. Browse in to /repository/deployment/server/jaggeryapps/store/extensions/assets Create a folder with name "applications"    Now we can override the files in /repository/deployment/server/jaggeryapps/store/extensions/app/greg-store-defaults   Since we are overriding the details page we need to...