Maintain Aspect Ratio Mixin
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的更多相关文章
- [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 ...
- 利用ImageOps调整图片的Aspect Ratio(给图片添加borders)
# -*- coding: utf-8 -*- #******************** # 改变图片的纵横比(aspect retio) # 使用ImageOps.expand() # Image ...
- Volley(三)—— ImageRequest & Request简介
Volley(三)—— ImageRequest & Request简介 上 篇文章我们讲 到了如何用volley进行简单的网络请求,我们可以很容易的接受到string.JsonObjec类型 ...
- Using FireMonkey Layouts
FireMonkey has many layout controls to choose from. Come learn the differences and how to use them t ...
- Babylon.GUI官方文档翻译
Babylon.GUI是一个基于Babylon.js的WebGL库,可以用来在WebGL3D场景中生成交互性UI与动态纹理.相比于html ui,Babylon.GUI的功能较为简化,但使用起来也更加 ...
- OpenCV手写数字字符识别(基于k近邻算法)
摘要 本程序主要参照论文,<基于OpenCV的脱机手写字符识别技术>实现了,对于手写阿拉伯数字的识别工作.识别工作分为三大步骤:预处理,特征提取,分类识别.预处理过程主要找到图像的ROI部 ...
- 通用的Bitmap压缩算法,进一步节约内存(推荐)
前几天我写了一篇通过压缩Bitmap,减少OOM的文章,那篇文章的目的是按照imageview的大小来压缩bitmap,让bitmap的大小正好是imageview.但是那种算法的通用性比较差,仅仅能 ...
- 详细解读Volley(二)—— ImageRequest & Request简介
上篇文章我们讲到了如何用volley进行简单的网络请求,我们可以很容易的接受到string.JsonObjec类型的返回结果,之前的例子仅仅是一次请求,这里需要说明volley本身就是适合高并发的,所 ...
- php_imagick超强的PHP图片处理扩展
php_imagick是一个可以供PHP调用ImageMagick功能的PHP扩展,使用这个扩展可以使PHP具备和ImageMagick相同的功能. ImageMagick是一套功能强大.稳定而且 ...
随机推荐
- 换个语言学一下 Golang (2)——基础语法
Go 标记 Go 程序可以由多个标记组成,可以是关键字,标识符,常量,字符串,符号.比如下面的hello world就是由 6 个标记组成: 行分隔符 在 Go 程序中,一行代表一个语句结束.每个语句 ...
- JS 写<ul><li>
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Linux搭建oracle数据库
1.安装前准备 软件硬件要求 操作系统:CentOS 6.4(32bit)Oracle数据库版本:Oracle 10g(10201_database_linux32.zip)最小内存:1G(检查命 ...
- js 操作table: insertRow(),deleteRow(),insertCell(),deleteCell()方法
表格有几行: var trCnt = table.rows.length; (table为Id ) 每行有几列:for (var i=0; i<trCnt; i++) ...
- maven引入spring相关依赖
<!--spring相关包--> <dependency> <groupId>org.springframework</groupId> <art ...
- String与StringBuffer与StringBuilder
package test; public class Test { public static void main(String[] args) { StringBuffer sb = new Str ...
- 可序列化serializable的作用是什么
什么情况下需要序列化:a)当你想把的内存中的对象写入到硬盘的时候:b)当你想用套接字在网络上传送对象的时候: 为什么要序列化: 为了将对象可以以流的方式传输到其他位置,就必须要将该对象定义为可序列化的 ...
- 0111mysql如何选择Join的顺序
本文通过一个案例来看看MySQL优化器如何选择索引和JOIN顺序.表结构和数据准备参考本文最后部分"测试环境".这里主要介绍MySQL优化器的主要执行流程,而不是介绍一个优化器的各 ...
- 《Python 源码阅读》之 类型Type
py一切皆对象: 那么Type也是个对象.对象类型叫PyTypeObject demo >>> a = 1 >>> a 1 >>> type(a) ...
- 【LeetCode-面试算法经典-Java实现】【120-Triangle(三角形)】
[120-Triangle(三角形)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Given a triangle, find the minimum path s ...