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是一套功能强大.稳定而且 ...
随机推荐
- Kafka学习笔记(7)----Kafka使用Cosumer接收消息
1. 什么是KafkaConsumer? 应用程序使用KafkaConsul'le 「向Kafka 订阅主题,并从订阅的主题上接收消息.Kafka的消息读取不同于从其他消息系统读取数据,它涉及了一些独 ...
- Flask框架函数
title: flask学习笔记 subtitle: 1. flask框架函数 date: 2018-12-14 10:17:28 --- Flask学习 学习Miguel Grinberg的2017 ...
- BZOJ 5508: [Tjoi2019]甲苯先生的字符串 矩阵乘法_思维
求 $f[i][j]=∑f[i−1][k]$,$'a'<=k<='z'$ . 用矩阵乘法转移一波即可. 竟然独自想出来了QAQ Code: #include <bits/stdc++ ...
- python的jieba分词
# 官方例程 # encoding=utf-8 import jieba seg_list = jieba.cut("我来到北京清华大学", cut_all=True) print ...
- 微电影《Junior·BQB》——剧本
电影名称:<Junior——BQB> 组长: 组员: 导演: 副导演: 分镜/演出: 编剧: 主演: 彬彬:比丘 阿伟:魔女(彬彬姐) 小怪:怪物团长 客串 旁白 友情演出: 恶俗之王 摄 ...
- 3.2、Ansible单命令测试
0.Ansible的group支持all.通配符(*).IP地址 1.查看Ansible的版本 $ ansbile --version [root@test ~]# ansible --versi ...
- 2015 Multi-University Training Contest 8 hdu 5381 The sum of gcd
The sum of gcd Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)To ...
- JavaScript之this释疑
近期进修JavaScript,看了"You Don't Know JS"这本书,认为是本JavaScript内功上乘心法,有一定JavaScript基础朋友一定要看看(不推荐入门小 ...
- iOS动画之美丽的时钟
1.终于效果图 2.实现思路 在ios中默认是绕着中心点旋转的,由于锚点默认在图层的中点,要想绕着下边中心点转,须要改变图层锚点的位置. 依据锚点.设置position坐标.为时钟的中点. 思考秒针旋 ...
- java中super的作用
super()的作用 super能够用来訪问超类的构造方法和被子类所隐藏的方法.假设子类中有方法与超类中的方法名称和參数同样,则超类中的方法就被隐藏起来,也就是说在子类中重载了父类中的方法. 引用父类 ...