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是一套功能强大.稳定而且 ...
随机推荐
- 场景报错Error -27492: "HttpSendRequest" failed, Windows error code=12029 (cannot connect) and retry limit (0) exceeded for URL=""
1.现象:loadrunner场景执行,tps图是一段很平稳,然后直线触底,一段时间,直线恢复平稳,触底这段时间报错信息如下: Action.c(6): Error -27492: "Htt ...
- SpringMVC(二)@RequestMapping
学习@RequestMapping注解,参考Spring API 1.@RequestMapping可以修饰在类类型和方法上 ①.修饰在类定义上: 提供初步的URL映射,相对于web应用 ...
- bzoj 1296: [SCOI2009]粉刷匠 动态规划
Description windy有 N 条木板需要被粉刷. 每条木板被分为 M 个格子. 每个格子要被刷成红色或蓝色. windy每次粉刷,只能选择一条木板上一段连续的格子,然后涂上一种颜色. 每个 ...
- Alios-Things的学习与使用(1)
目录 Alios-Things的学习与使用 1.简介 1.1 为什么要学alios-Things 2. 环境搭建 2.1 使用docker toolbox安装docker 2.2 测试使用dockde ...
- WEBGL学习【八】模型视图投影矩阵
<!--探讨WEBGL中不同图形的绘制方法:[待测试2017.11.6]--> <!DOCTYPE HTML> <html lang="en"> ...
- There are no packages available for installation. Sublime3解决方法
最近在学习Vue,在配置sublime3的时候,想要高亮vue的语法,下载点插件 Package Control的时候,总报 There are no packages available for ...
- [洛谷 P1967] 货车运输 (最大生成树 lca)
题目描述 A 国有 n 座城市,编号从 1 到 n,城市之间有 m 条双向道路.每一条道路对车辆都有重量限制,简称限重.现在有 q 辆货车在运输货物, 司机们想知道每辆车在不超过车辆限重的情况下,最多 ...
- [JoyOI] 1035 棋盘覆盖 (二分图匹配)
题目描述 给出一张nn(n<=100)的国际象棋棋盘,其中被删除了一些点,问可以使用多少12的多米诺骨牌进行掩盖. 输入格式 第一行为n,m(表示有m个删除的格子) 第二行到m+1行为x,y,分 ...
- Spring 使用外部属性文件配置
1.Spring提供了一个PropertyPlaceholderConfigurer的BeanFactory后置处理器,这个处理器允许用户将Bean的配置的部分内容 移到属性文件中.可以在Bean配置 ...
- PHP图片验证码处理