Some Html CSS tips and tricks

Some Html CSS tips and tricks Trick No. 1:We often need to use clear in our html so insted of using:
<divstyle="clear: both"></div> OR <divclass="clear"></div>

We can make use of pseudo selector :after,like this: ———–

.container {
        /*dummy attributes*/
        height:100%;
        width:100%
        margin:5px;
}
.container :after {
        display: block;
        clear: both;
        content: " ";
        height: 0;
        overflow: hidden;
}
.container childDiv {
       float:left;
}
——
It makes more sense if we are using LESS,as we can create a mixin for this as:
.clearfix() {
        &:after {
              display: block;
              clear: both;
              content: " ";
              height: 0;
              overflow: hidden;
       }
}
and then we can call this in our class,like this:
.container {
        /* this div has two floated child,*/
        /* so we must clear left/right after this div.*/
        /* calling the mixin,which will take care of clear.*/
        .clearfix;
        .div1 {
              float:left;
        }      
        .div2 {
              float:right;
        }
 }
Trick No. 2last-child/first-child are another pseudo selector,which are very useful,so if we want to apply some additional attributes to last/first child of certain class,we can use these selector. This is how these can be used:
.class-name {
     /* dummy attributes */
     height:100%;
     width:100%
     margin:5px;
 }
 .class-name:last-child {
     margin:0px;
 }
Trick No. 3:To select the next element, we can use + selector:
.class-name + span {
        /*dummy attributes*/
        height:100%;
        width:100%
        margin:5px;
 }
it will select the next span element. We can also select the next element with class name.

.class-name + .some-class {
        /* dummy attributes */
 }
Trick No. 4:If we want to make some portion of image clickable (hot spot),then we can insert an anchor with absolute position, e.g.:
.container {
       background: url('../images/container-bg.png') no-repeat;
       height:75px;
       width:75px;
       position:relative;
 }
 .hot-spot {
       position: absolute;
       bottom:0;
       right:0;
       height:28px;
       width: 28px;
       display: block;
       content:"";
 }
HTML for this
<div class="container">
        <!-- We can place this anchor anywhere under this div -->
        <a class=".hot-spot" href="#" alt="hot spot"></a>
        <!-- dummy text -->
        <p>
                Lorem ipsum dolor sit amet.Etiam a ipsum id purus.
        </p>
<div>
Note: if the element is positioned absolute, then its parent must be positioned relative.
Trick No. 5: For browser specific css, instead of creating different css/less files we should use this:
<!--[if IE 8 ]><head class="ie8"><![endif]-->
<!--[if (IE 9) |!(IE)]><!--><head><!--<![endif]-->
And define this class “ie8″ in the same css/less file. Happy Coding!!

Import Export Content in Different Languages in Sitecore

Below image show content of a sample item in English language in fresh Sitecore instance.

Export

Now we will export it using Export language to a file wizard and Sitecore generates below XML

<sitecore>
<phrase path="/sitecore/content/Home/Sample Item" key="Sample Item" itemid="{9B53F11E-C767-4939-9587-E81FD1C401B1}" fieldid="Title" updated="20120921T155939">
<en>Sample Item</en>
</phrase>
<phrase path="/sitecore/content/Home/Sample Item" key="Sample Item" itemid="{9B53F11E-C767-4939-9587-E81FD1C401B1}" fieldid="Text" updated="20120921T155939">
<en>&lt;p&gt;Mitigate your risk and speed up time to market with our integrated solutions.&lt;/p&gt;</en>
</phrase>
</sitecore>

As we can see we have English content between the <en> tag.

Now, we will add content in some other languages.

It’s a very simple process, as we need to add content between the language specfic tag e.g., if we want to have content in French then we can add <fr> tag and we can add French content here.

Please note that we have to use language specific tags to enter content in that language. If you enter content of different language under<en>it will replace English language content for an item during import.

Now we have updated this xml to include translated content from different languages and produce below XML.

<sitecore>
<phrase path="/sitecore/content/Home/Sample Item" key="Sample Item" itemid="{9B53F11E-C767-4939-9587-E81FD1C401B1}" fieldid="Title"
updated="20120921T155350">
<en>Sample Item</en>
<fr>Article échantillon</fr>
<da>Sample Item</da>
<es>Muestra del artículo</es>
<ja-JP>サンプルアイテム</ja-JP>
</phrase>
<phrase path="/sitecore/content/Home/Sample Item" key="Sample Item" itemid="{9B53F11E-C767-4939-9587-E81FD1C401B1}" fieldid="Text"
updated="20120921T155350">
<en>&lt;p&gt;Mitigate your risk and speed up time to market with our integrated solutions.&lt;/p&gt;</en>
<fr>&lt;p&gt;Atténuer les risques et d'accélérer les délais de commercialisation de nos solutions intégrées.&lt;/p&gt;</fr>
<da>&lt;p&gt;Mindske din risiko og fremskynde time to market med vores integrerede løsninger.&lt;/p&gt;</da>
<es>&lt;p&gt;Mitigar el riesgo y acelerar el tiempo de comercialización de nuestras soluciones integradas.&lt;/p&gt;</es>
<ja-JP>&lt;p&gt;あなたのリスクを軽減し、当社の統合ソリューションを市場に出すまでの時間をスピードアップ。&lt;/p&gt;</ja-JP>
</phrase>
</sitecore>

When we imported above XML file in Sitecore it will automatically create different language version of Sitecore item present in file. After importing above xml file in Sitecore we can see 4 more languages items gets created for Sample Item. In below image we have select Japanese Version of Sample Item.

Import

Please note that if you don’t specify the language tag<fr> </fr>Sitecore will not detect the language while import.