wap(html)知识点整理(持续更新)
1、px、em、rem的关系
px为固定大小
em/rem为相对大小,其中em相对其父节点,rem相对html根节点
2、google浏览器无法设置1rem=10px问题
在把px转换成rem的过程中,会在设置html的css的font-size为62.5%已使得在进行px到rem的转换中1rem=10px。但是这种方式在chrome中不起作用,这样设置之后1rem=12px,这是因为chrome认为字体的最小为12px,你设置1rem等于10px,chrome强制转换成1rem=12px。
把html的font-size设置成625%,那么1rem=100px就可以了。
3、右边固定宽度,左边自适应问题;左边固定,右边自适应问题
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div>左边固定,右边自适应(一定记住要clear float)</div>
<div>
<div style="width: 200px; height: 200px;float: left;background-color: gray;">
200X200
</div>
<div style="height: 200px; margin-left: 200px;background-color: purple;color: white;"> 自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!自适应宽度!!!
</div>
<div style="clear: both;"></div>
</div>
<hr/>
<div>右边固定,左边自适应(一定记住要clear float)</div>
<div>
<div style="width: 100%;height: 200px; margin-left: -200px; float: left;background-color:purple;">
<div style="margin-left: 200px;color: white;">通过margin-left为负数来固定右侧内容,同时设置内部的div的margin-left为整数来调整显示范围。通过margin-left为负数来固定右侧内容,同时设置内部的div的margin-left为整数来调整显示范围。通过margin-left为负数来固定右侧内容,同时设置内部的div的margin-left为整数来调整显示范围。</div>
</div>
<div style="width: 200px; height: 200px; float:left;background-color:gray;">
200X200
</div>
<div style="clear: both;"></div>
</div>
</body>
4、让body的height高为100%
之前直接设置body的height为100%,发现没有用。后面发现需要把html和body同时设置heigth为100%。
5、touchend无法触发
在touchstart触发时调用event.preventDefault();方法就可以了。
6、禁止双击放大网页
加入meta,进行限制
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
7、禁止浏览器滚动条
overflow-x: hidden;
overflow-y: hidden;
8、textarea固定大小
resize: none;
9、button上的文字换行
两行文字中加入 谷歌测试有效
<input type="button" value="第一行 第二行" />