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. 关于《Python核心编程》第2版和第3版

    关于<Python核心编程>第2版和第3版 以前开始学Python的时候,根据某大神的建议买了本<Python核心编程>第2版,慢慢学习.而最近回家没带书回来,刚好JD有活动, ...

  2. 使用dom4j生成word的方法

    http://blog.csdn.net/zhyh1986/article/details/8727523#t6 http://blog.csdn.net/zuozuofuwaiwai/article ...

  3. DAO DTO VO BO

    DAO叫数据访问对象DTO是数据传输对象DAO通常是将非对象数据(如关系数据库中的数据)以对象的方式操纵.DTO通常用于不同层(UI层.服务层或者域模型层)直接的数据传输,以隔离不同层,降低层间耦合 ...

  4. Nginx全局变量

    一.全局变量 $args #请求中的参数值 $query_string #同 $args $arg_NAME #GET请求中NAME的值 $is_args #如果请求中有参数,值为"?&qu ...

  5. C语言基础 (5) 常用操作符

    01 课程回顾 变量的起名:字母数字下划线 不能是关键字 常量 变量提升:老的编译器这样会报错 运算符:sizeof.+.-.x … … 进制: 1111 8421 计算机几乎都是二进制系统,而且是以 ...

  6. 阿里云服务上面部署redis + 本地Redis客户端连接方法

    本文结合自己在阿里云服务器上面搭建redis服务器,在本地redis的客户端Redis Desktop Manager连接成功的操作,将操作中的一些方法做了一些归纳和总结,希望可以帮到有需要的同学. ...

  7. UEditor如何读取数据库信息?

    你用的什么语言,服务器端生成的时候,直接写在里面就可以了啊,比如 <textarea name="content" cols="800" rows=&qu ...

  8. [SDOI2018]战略游戏(圆方树+虚树)

    喜闻乐见的圆方树+虚树 图上不好做,先建出圆方树. 然后答案就是没被选到的且至少有两条边可以走到被选中的点的圆点的数量. 语文不好,但结论画画图即可得出. 然后套路建出虚树. 发现在虚树上DP可以得出 ...

  9. 编写 Node.js Rest API 的 10 个最佳实践

    Node.js 除了用来编写 WEB 应用之外,还可以用来编写 API 服务,我们在本文中会介绍编写 Node.js Rest API 的最佳实践,包括如何命名路由.进行认证和测试等话题,内容摘要如下 ...

  10. Python 使用matplotlib模块模拟掷骰子

    掷骰子 骰子类 # die.py 骰子类模块 from random import randint class Die(): """骰子类""&quo ...