Maintain Aspect Ratio Mixin

Maintain the aspect ratio of a div with CSS

RESPONSIVE ASPECT RATIOS WITH PURE CSS

How to Maintain Image Aspect Ratios in Responsive Web Design

http://www.w3.org/TR/2011/REC-CSS2-20110607/box.html#padding-properties

example code 1

/*
* Pure CSS aspect ratio with no spacer images or js! :)
*/ body {
width: 36%;
margin: 8px auto;
} div.stretchy-wrapper {
width: 100%;
padding-bottom: 56.25%; /* 16:9 */
position: relative; background: blue;
} div.stretchy-wrapper > div {
position: absolute;
top: 0; bottom: 0; left: 0; right: 0; color: white;
font-size: 24px;
text-align: center;
} /* Other aspect ratios to try:
* 56.25% = 16:9
* 75% = 4:3
* 66.66% = 3:2
* 62.5% = 8:5
*/
<div class="stretchy-wrapper"><div>Resize your browser</div></div>

example 2

<section class="ejemplo">
<h1>Aspect ratios pure Css: widths rule</h1>
<h2>Resize the window</h2>
<div class="width ratio2-1">
<div class="contenido">Aspect ratio 2:1</div>
</div>
<div class="width ratio16-9">
<div class="contenido">Aspect ratio 16:9</div>
</div>
<div class="width ratio4-3">
<div class="contenido">Aspect ratio 4:3</div>
</div>
<div class="width ratio1-1">
<div class="contenido">Aspect ratio 1:1</div>
</div>
</section>
<p><a href='http://ksesocss.blogspot.com/2013/08/aspect-ratios-css.html'>The post (es-es)</a></p>
<p>See the second part: <a href='http://codepen.io/Kseso/pen/rouEi'>when heights rule</a></p>
@import url(http://fonts.googleapis.com/css?family=Dosis:300);
* {
margin: 0;
padding: 0;
border: 0 none;
position: relative;
}
html, body {
background: #164C88;
font-family: Dosis;
font-size: 1.1rem;
line-height: 1.6;
color: #F6FAFD;
}
body {padding: 1rem;}
.ejemplo {
text-align: center;
}
.width {
width: 45%;
background: #F9D237;
position: relative;
display: inline-block;
margin: 1%;
vertical-align: top;
box-shadow: 0 0 4px rgba(0,0,0,.3);
}
.width:before {
content: '';
display: block;
}
.ratio1-1:before {padding-top: 100%;}
.ratio2-1:before {padding-top: 50%;}
.ratio4-3:before {padding-top: 75%;}
.ratio16-9:before {padding-top: 56.25%;}
.contenido {
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
font-size: 1.5rem;
color: #444;
}
a {color: #F9D237}

Maintain Aspect Ratio Mixin的更多相关文章

  1. [CSS] Control Image Aspect Ratio Using CSS

    Resize images and videos to fill their parent and maintain their aspect ratio with pure CSS. The new ...

  2. 利用ImageOps调整图片的Aspect Ratio(给图片添加borders)

    # -*- coding: utf-8 -*- #******************** # 改变图片的纵横比(aspect retio) # 使用ImageOps.expand() # Image ...

  3. Volley(三)—— ImageRequest & Request简介

    Volley(三)—— ImageRequest & Request简介 上 篇文章我们讲 到了如何用volley进行简单的网络请求,我们可以很容易的接受到string.JsonObjec类型 ...

  4. Using FireMonkey Layouts

    FireMonkey has many layout controls to choose from. Come learn the differences and how to use them t ...

  5. Babylon.GUI官方文档翻译

    Babylon.GUI是一个基于Babylon.js的WebGL库,可以用来在WebGL3D场景中生成交互性UI与动态纹理.相比于html ui,Babylon.GUI的功能较为简化,但使用起来也更加 ...

  6. OpenCV手写数字字符识别(基于k近邻算法)

    摘要 本程序主要参照论文,<基于OpenCV的脱机手写字符识别技术>实现了,对于手写阿拉伯数字的识别工作.识别工作分为三大步骤:预处理,特征提取,分类识别.预处理过程主要找到图像的ROI部 ...

  7. 通用的Bitmap压缩算法,进一步节约内存(推荐)

    前几天我写了一篇通过压缩Bitmap,减少OOM的文章,那篇文章的目的是按照imageview的大小来压缩bitmap,让bitmap的大小正好是imageview.但是那种算法的通用性比较差,仅仅能 ...

  8. 详细解读Volley(二)—— ImageRequest & Request简介

    上篇文章我们讲到了如何用volley进行简单的网络请求,我们可以很容易的接受到string.JsonObjec类型的返回结果,之前的例子仅仅是一次请求,这里需要说明volley本身就是适合高并发的,所 ...

  9. php_imagick超强的PHP图片处理扩展

      php_imagick是一个可以供PHP调用ImageMagick功能的PHP扩展,使用这个扩展可以使PHP具备和ImageMagick相同的功能. ImageMagick是一套功能强大.稳定而且 ...

随机推荐

  1. 00--C++牛人的博客

    那些C++牛人的博客 这篇文章来自转载,转载的网址找不到了,   如果有人知道,可以在下面评论,   非常感谢,更感谢原作者. 现整理收集C++世界里那些“牛人”的个人博客.凡三类:一是令人高山仰止的 ...

  2. 脚本自动化部署varnish源码包

    #!bin/bash#功能:自动化部署 varnish 源码包软件,运行脚本前,需提前下载 varnish-5.0.0.tar.gz#作者:liusingbonyum -y install gcc r ...

  3. GDI Bezier 样条曲线(7)

    Bezier 样条曲线 Bezier 样条曲线使用四个点来定义:两个端点(起点和终点)和两个控点(用于使其不同程度地弯曲). 绘制 Bezier 样条曲线 使用 PolyBezier 函数和 Poly ...

  4. redis各数据类型应用概述

    前言 redis是一个开源的使用ANSI C语言编写.支持网络.可基于内存.亦可持久化的日志型.key-value数据库,并提供多种语言的API. 它是内存存储的数据结构服务器,可用作数据库.高速缓存 ...

  5. maven引入spring相关依赖

    <!--spring相关包--> <dependency> <groupId>org.springframework</groupId> <art ...

  6. 对Java线程安全与不安全的理解

    当我们查看JDK API的时候,总会发现一些类说明写着,线程安全或者线程不安全,比如说到StringBuilder中,有这么一句,"将StringBuilder 的实例用于多个线程是不安全的 ...

  7. html--onreadystatechange属性

  8. codevs——T1044 拦截导弹 || 洛谷——P1020 导弹拦截

    http://codevs.cn/problem/1044/ || https://www.luogu.org/problem/show?pid=1020#sub 时间限制: 1 s  空间限制: 1 ...

  9. 基于STM32的学习型通用红外遥控设备的设计实现(三)

    CPU: STM32 调试平台: STM32F103ZET和STM32F103VBT 软件平台: Keil uVision4 电路设计: Altium Designer v6.9 http://blo ...

  10. ubuntu中写一个shell脚本的过程

    gedit hello.sh ,然后输入 #!/bin/bash echo "Hello world!" chmod +x hello.sh ./hello.sh