小知识点整理
2015-08-12 11:27
260 查看
1、img一般要设置display:block,解决空白问题;
2、移动端H5,图片自适应问题,宽与高,用大值除以小值,获得的值设置父元素DIV的padding-top;
<div class="topic"><img src="images/topic.jpg" alt="资源开放说明与进驻登记"></div>
.topic{position:relative;padding-top:177.5%;background-color:#891f35;}
.topic img{position:absolute;left:0;top:0;width:100%;height:100%;}
上面是为了图片还没加载出来时,先占位,而且设置一个跟图片差不多的背景颜色。记得图片的alt属性还是写上较好;
3、移动端H5,width与heigh,font-size的设定,参考设计图的数字/2;切图时切偶数值;
<div class="title">一站式满足家长求助、求知、社交需求</div>
.platform .title{margin:0 auto 1em auto;width:247px;height:31px;background:url(images/title-bg.png) 0 0 no-repeat;background-size:contain;
font-size:13px;text-align:center;line-height:31px;
}
设置DIV的宽高为背景图片的一半,使用background-size:contain(把图像图像扩展至最大尺寸,以使其宽度和高度完全适应内容区域。)
2、移动端H5,图片自适应问题,宽与高,用大值除以小值,获得的值设置父元素DIV的padding-top;
<div class="topic"><img src="images/topic.jpg" alt="资源开放说明与进驻登记"></div>
.topic{position:relative;padding-top:177.5%;background-color:#891f35;}
.topic img{position:absolute;left:0;top:0;width:100%;height:100%;}
上面是为了图片还没加载出来时,先占位,而且设置一个跟图片差不多的背景颜色。记得图片的alt属性还是写上较好;
3、移动端H5,width与heigh,font-size的设定,参考设计图的数字/2;切图时切偶数值;
<div class="title">一站式满足家长求助、求知、社交需求</div>
.platform .title{margin:0 auto 1em auto;width:247px;height:31px;background:url(images/title-bg.png) 0 0 no-repeat;background-size:contain;
font-size:13px;text-align:center;line-height:31px;
}
设置DIV的宽高为背景图片的一半,使用background-size:contain(把图像图像扩展至最大尺寸,以使其宽度和高度完全适应内容区域。)
相关文章推荐
- 02_08 JSP内置对象之Web安全性及config对象
- Android取消EditText自动获取焦点默认行为
- http状态码
- Swift:闭包(Closures)
- dede让channelartlist标签支持currentstyle属性 完美解决
- 第九章 单处理器调度
- python系列--django
- HDU1260 Tickets
- android Activity之间数据传递 Parcelable和Serializable接口的使用
- vmware vms migration to openstack
- 前端数据可视化插件(一)图表
- POJ3279Fliptile【经典搜索】
- 企业招聘,慎选BAT出来的人
- cmake 那些事儿~
- window下weblogic安装教程
- hdu 1085 面值为1.2.5的硬币不能组成的最小面值
- POJ 1478
- 字符串hash函数
- android Process 18869 exceeded cursor quota 100, will kill it
- 权限拦截器