Vertical Centering in CSS

<div id="containter">
        everything is vertically centered here.
</div>
<style>
#containter {
    height: 400px;
    display: flex;
    /* flex-direction: column;*/
    align-items: center; 
    /* justify-content: center;*/
}
</style>
Advertisements

CSS Styled Checkbox

Custom Checkbox Sample


       
/* Remove default checkbox */
[type="checkbox"]:not(:checked),
[type="checkbox"]:checked {
  position: absolute;
  left: -9999px;
  visibility: hidden; }

[type="checkbox"] {
  /* checkbox aspect */ }
  [type="checkbox"] + label {
    position: relative;
    padding-left: 35px;
    cursor: pointer;
    display: inline-block;
    height: 25px;
    line-height: 25px;
    font-size: 1rem;
    -webkit-user-select: none;
    /* webkit (safari, chrome) browsers */
    -moz-user-select: none;
    /* mozilla browsers */
    -khtml-user-select: none;
    /* webkit (konqueror) browsers */
    -ms-user-select: none;
    /* IE10+ */ }
  [type="checkbox"] + label:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 18px;
    height: 18px;
    z-index: 0;
    border: 2px solid #5a5a5a;
    border-radius: 1px;
    margin-top: 2px;
    -webkit-transition: 0.2s;
    -moz-transition: 0.2s;
    -o-transition: 0.2s;
    -ms-transition: 0.2s;
    transition: 0.2s; }
  [type="checkbox"]:not(:checked):disabled + label:before {
    border: none;
    background-color: rgba(0, 0, 0, 0.26); }

[type="checkbox"]:checked + label:before {
  top: -4px;
  left: -3px;
  width: 12px;
  height: 22px;
  border-top: 2px solid transparent;
  border-left: 2px solid transparent;
  border-right: 2px solid #4CAF50;  /*Original code #ff4081*/
  border-bottom: 2px solid #4CAF50; /*Original code #ff4081*/
  -webkit-transform: rotate(40deg);
  -moz-transform: rotate(40deg);
  -ms-transform: rotate(40deg);
  -o-transform: rotate(40deg);
  transform: rotate(40deg);
  -webkit-backface-visibility: hidden;
  -webkit-transform-origin: 100% 100%;
  -moz-transform-origin: 100% 100%;
  -ms-transform-origin: 100% 100%;
  -o-transform-origin: 100% 100%;
  transform-origin: 100% 100%; }
[type="checkbox"]:checked:disabled + label:before {
  border-right: 2px solid rgba(0, 0, 0, 0.26);
  border-bottom: 2px solid rgba(0, 0, 0, 0.26); }

/* Indeterminate checkbox */
[type="checkbox"]:indeterminate + label:before {
  left: -10px;
  top: -11px;
  width: 10px;
  height: 22px;
  border-top: none;
  border-left: none;
  border-right: 2px solid #ff4081;
  border-bottom: none;
  -webkit-transform: rotate(90deg);
  -moz-transform: rotate(90deg);
  -ms-transform: rotate(90deg);
  -o-transform: rotate(90deg);
  transform: rotate(90deg);
  -webkit-backface-visibility: hidden;
  -webkit-transform-origin: 100% 100%;
  -moz-transform-origin: 100% 100%;
  -ms-transform-origin: 100% 100%;
  -o-transform-origin: 100% 100%;
  transform-origin: 100% 100%; }
[type="checkbox"]:indeterminate:disabled + label:before {
  border-right: 2px solid rgba(0, 0, 0, 0.26);
  background-color: transparent; }

[type="checkbox"].filled-in + label:after {
  border-radius: 2px; }
[type="checkbox"].filled-in + label:before,
[type="checkbox"].filled-in + label:after {
  content: '';
  left: 0;
  position: absolute;
  /* .1s delay is for check animation */
  transition: border .25s, background-color .25s, width .20s .1s, height .20s .1s, top .20s .1s, left .20s .1s;
  z-index: 1; }
[type="checkbox"].filled-in:not(:checked) + label:before {
  width: 0;
  height: 0;
  border: 3px solid transparent;
  left: 6px;
  top: 10px;
  -webkit-transform: rotateZ(37deg);
  transform: rotateZ(37deg);
  -webkit-transform-origin: 20% 40%;
  transform-origin: 100% 100%; }
[type="checkbox"].filled-in:not(:checked) + label:after {
  height: 20px;
  width: 20px;
  background-color: transparent;
  border: 2px solid #5a5a5a;
  top: 0px;
  z-index: 0; }
[type="checkbox"].filled-in:checked + label:before {
  top: 0;
  left: 1px;
  width: 8px;
  height: 13px;
  border-top: 2px solid transparent;
  border-left: 2px solid transparent;
  border-right: 2px solid #fff;
  border-bottom: 2px solid #fff;
  -webkit-transform: rotateZ(37deg);
  transform: rotateZ(37deg);
  -webkit-transform-origin: 100% 100%;
  transform-origin: 100% 100%; }
[type="checkbox"].filled-in:checked + label:after {
  top: 0px;
  width: 20px;
  height: 20px;
  border: 2px solid #ff4081;
  background-color: #ff4081;
  z-index: 0; }
[type="checkbox"].filled-in:disabled:not(:checked) + label:before {
  background-color: transparent;
  border: 2px solid transparent; }
[type="checkbox"].filled-in:disabled:not(:checked) + label:after {
  border-color: transparent;
  background-color: #BDBDBD; }
[type="checkbox"].filled-in:disabled:checked + label:before {
  background-color: transparent; }
[type="checkbox"].filled-in:disabled:checked + label:after {
  background-color: #BDBDBD;
  border-color: #BDBDBD; }

    <p>
        <input id="Checkbox1" type="checkbox" />
        <label for="Checkbox1">Checkbox</label>
    </p>

    <p>
        <input id="Checkbox2" type="checkbox" class="filled-in" />
        <label for="Checkbox2">Teletalk</label>
    </p>

CSS- Select nth td of a tr of table

.inline-table tr td:nth-child(3) {
    text-align:right;
}
<table>
    <tbody id="SearchResultTableBody">
        <tr>
            <td>
                <img />
            </td>

            <td>
            </td>

            <td>
                <div>
                    <img />
                </div>

                <div>
                    <table class="inline-table">
                        <tr>
                            <td></td>
                            <td></td>
                            <td></td> <!--only this'll be selected-->
                        </tr>
                    </table>
                </div>

                <div>
                    <div>
                        <div>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </tbody>
</table>

CSS- Select only direct nth child(s)

#SearchResultTableBody > tr > td > div:nth-child(3) {
    margin-left:10px;
}
<table>
    <tbody id="SearchResultTableBody">
        <tr>
            <td>
                <div> <!--This div will not be selected-->                   
                </div>

                <div> <!--This div will not be selected--> 
                </div>

                <div> <!--Only this div will be selected-->
                    <div> <!--This div will not be selected--> 
                        <div> <!--This div will not be selected--> 
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </tbody>
</table>

CSS- Select only direct child(s)

#TBody > tr > td > div {
    float: left;
}
<table>
    <tbody id="TBody">
        <tr>
            <td>
                <img />
            </td>

            <td>
            </td>

            <td>
                <div> <!--This div will be selected-->
                    <img />
                </div>

                <div> <!--This div will be selected-->
                    <table class="inline-table">
                        <tr>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                    </table>
                </div>

                <div> <!--This div will be selected-->
                    <div> <!--This div will not be selected-->
                        <div> <!--This div will not be selected-->
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </tbody>
</table>

Spin/Rotate an image by CSS

.imagee {
    overflow: hidden;
    transition-duration: 0.8s;
    transition-property: transform;
}

.imagee:hover {
    transform: rotate(360deg);
}

.imageee {
    margin: -60px 0 0 -60px;
    -webkit-animation: spin 2s linear infinite;
    -moz-animation: spin 2s linear infinite;
    animation: spin 2s linear infinite;
}

@@-moz-keyframes spin {
    100% {
        -moz-transform: rotate(360deg);
    }
}

@@-webkit-keyframes spin {
    100% {
        -webkit-transform: rotate(360deg);
    }
}

@@keyframes spin {
    100% {
        -webkit-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

CSS Sprite Technique

CSS-

<style>
    a.traffic {
        display: block;
        height: 50px;
        overflow: hidden;
        position: relative;
        width: 50px;
    }

    a.traffic span {
        background: url('TrafficSprite.png') no-repeat;
        display: block;
        height: 100%;
        left: 0;
        position: absolute;
        top: 0;
        width: 100%;
    }

    a.traffic:hover span {
        background-position:  -48px 0;
    } 

</style>

HTML-

 <a class="traffic" href=""><span></span></a>

Here is the sample image-
TrafficSprite

Full Page Web Modal

<style>
#displaybox {
	z-index: 10000;
	filter: alpha(opacity=50); /*older IE*/
	filter:progid:DXImageTransform.Microsoft.Alpha(opacity=50); /* IE */
	-moz-opacity: .50; /*older Mozilla*/
	-khtml-opacity: 0.5;   /*older Safari*/
	opacity: 0.5;   /*supported by current Mozilla, Safari, and Opera*/
	background-color:#000000;
	position:fixed; top:0px; left:0px; width:100%; height:100%; text-align:center; vertical-align:middle;
}
</style>

function clicker(){
	var thediv=document.getElementById('displaybox');
	if(thediv.style.display == "none"){
		thediv.style.display = "";
		thediv.innerHTML = "<a href='#' onclick='return clicker();'>CLOSE WINDOW</a>";
	}else{
		thediv.style.display = "none";
		thediv.innerHTML = '';
	}
	return false;
}

The hidden displaybox div
<div id="displaybox" style="display: none;"></div>


A link that will execute and return the clicker javascript function onclick: 
<a href='#' onclick='return clicker();'>Open Window</a>

Original Source of this article is here

Vertically center alignment in BootStrap3

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>

<div class="row center" style="border:1px solid black;">
  <div class="col-sm-4" style="background-color:white;">
   test
  </div>    
<div class="col-sm-8 ">
  test </br>
  test </br>
  test </br>
  </div>    
</div>


CSS

.center {  
  display:flex;
   align-items:center !important; 
   text-align:center;       
}

@media ( min-width:768px ) {
.center {
      display:flex;
      align-items:center !important;     
      text-align:center;     
  }
}

@media ( min-width: 992px ) {
   .center {     
     display:flex;
       align-items:center !important;      
       text-align:center;          
    }
}

@media ( min-width: 1200px ) {
    .center {      
       display:flex;
        align-items:center !important;      
        text-align:center;        
    }
}

CodePen