Skip to content

Instantly share code, notes, and snippets.

@starryeyez024
Last active August 29, 2015 14:10
Show Gist options
  • Save starryeyez024/bbdf3b09d856138b3989 to your computer and use it in GitHub Desktop.
Save starryeyez024/bbdf3b09d856138b3989 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div class="body">
<div class="ratio">
<div class="fpp">
<div class="fpp-inner">
<div class="field--name-field-fpp-text-body"> More text perhaps, was on the dockett, we could never be sure. How many words will need to fit in the box?</div>
<div class="field--name-field-fpp-text-url"> And what if there's more? What then?</div>
</div>
</div>
</div>
</div>
// ----
// Sass (v3.4.7)
// Compass (v1.0.1)
// ----
* {
box-sizing: border-box;
}
@mixin vertical-center-with-ir (
$inner-name: ".block-inner",
$inner-width: 80%,
$container-height: auto)
{
#{$inner-name} {
height: 100%;
display: inline-block;
vertical-align: middle;
width: $inner-width;
position: absolute;
top: 0;
left: (100% - $inner-width) / 2;
&:before {
content: '';
display: inline-block;
height: 100%;
width: 0;
font-size: 0;
vertical-align: middle;
}
}
#{$inner-name}-inner {
display: inline-block;
vertical-align: middle;
width: 98%;
text-align: center;
}
}
///////////////////////////////////////
.body {
max-width: 50%;
}
.ratio {
position: relative;
height: 0;
width: 100%;
padding-top: percentage(1/3) !important; // this is the ratio of your container
background: #eee;
@include vertical-center-with-ir(".fpp");
}
* {
box-sizing: border-box;
}
.body {
max-width: 50%;
}
.ratio {
position: relative;
height: 0;
width: 100%;
padding-top: 33.3333333333% !important;
background: #eee;
}
.ratio .fpp {
height: 100%;
display: inline-block;
vertical-align: middle;
width: 80%;
position: absolute;
top: 0;
left: 10%;
}
.ratio .fpp:before {
content: '';
display: inline-block;
height: 100%;
width: 0;
font-size: 0;
vertical-align: middle;
}
.ratio .fpp-inner {
display: inline-block;
vertical-align: middle;
width: 98%;
text-align: center;
}
<div class="body">
<div class="ratio">
<div class="fpp">
<div class="fpp-inner">
<div class="field--name-field-fpp-text-body"> More text perhaps, was on the dockett, we could never be sure. How many words will need to fit in the box?</div>
<div class="field--name-field-fpp-text-url"> And what if there's more? What then?</div>
</div>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment