Skip to content

Instantly share code, notes, and snippets.

@devonmather
Last active December 22, 2015 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devonmather/6458316 to your computer and use it in GitHub Desktop.
Save devonmather/6458316 to your computer and use it in GitHub Desktop.
Various CSS Snippets
/* Center Items without floats */
.centeredItems {
text-align: center;
text-align: left; /*if you want left aligned items*/
}
.centeredItems .item {
display: inline-block;
zoom: 1;
*display: inline;
vertical-align: top;
width: 280px;
margin: 0 0 20px;
padding: 20px;
}
.Center without margin: 0 auto; {
left: 50%;
margin-left: -700px;
position: relative;
width: 1400px;
}
.Absolute-Center {
margin: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
/* The Magic Float Center Code */
.float_center {
float: right;
position: relative;
left: -50%; /* or right 50% */
text-align: left;
}
.float_center > .child {
position: relative;
left: 50%;
}
/* Animate CSS gradients */
button {
background-image: linear-gradient(#5187c4, #1c2f45);
background-size: auto 200%;
background-position: 0 100%;
transition: background-position 0.5s;
}
button:hover {
background-position: 0 0;
}
/* Flexible/Responsive iFrame */
.flexibleContainer {
position: relative;
padding-bottom: 50%;
padding-top: 30px;
height: 0;
overflow: hidden;
}
.flexibleContainer iframe,
.flexibleContainer object,
.flexibleContainer embed {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
/* remove img hover opacity movement */
img:hover {
opacity: 0.9;
-webkit-transform: rotate(0);
-moz-transform: rotate(0);
transform: rotate(0);
-webkit-backface-visibility: hidden;
position: relative;
}
/* Vertical Center in the unknown */
/* This parent can be any width and height */
.block {
text-align: center;
}
/* The ghost, nudged to maintain perfect centering */
.block:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -0.25em; /* Adjusts for spacing */
}
/* The element to be centered, can
also be of any width and height */
.centered {
display: inline-block;
vertical-align: middle;
width: 300px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment