css兼容性问题集

IE兼容性hack: 6减 7乘 8除

.ie6_7_8{
    color:blue; /*所有浏览器*/
    color:red\9; /*IE8以及以下版本浏览器*/
    *color:green; /*IE7及其以下版本浏览器*/
    _color:purple; /*IE6浏览器*/
}

input textarea等输入框,在苹果ios显示有内阴影、圆角边框、按钮渐变透明bug

input输入框,苹果ios显示有内阴影
苹果ios 输入框圆角bug

  • 内阴影、按钮渐变透明:
    {appearance: none; -moz-appearance: none; -webkit-appearance: none;}
  • 圆角:
    {border-radius:0;}

限制input type=”file”上传文件类型

  • 正常写法:
<input type="file" value="上传图片">

效果如下:
andriod效果图

<input accept="image/*" type="file" value="上传图片">

<input type="file" name="pic" id="pic" accept="image/gif, image/jpeg" />

andriod效果如下:
andriod效果图

iOS效果如下:
IOS效果图


display:inline-block 间距bug

<div class="alert-action">
    <a class="btn-cancel" onclick="alert_hide()">取消</a>
    <a class="btn-confirm" onclick="alert_hide()">发送</a>
</div>

<style>
.alert-action{width:100%;/* height:40px; */line-height: 40px;text-align: center;}
.alert .btn-cancel,.alert .btn-confirm{height:100%;display:inline-block;width:50%;}
.alert .btn-cancel{background:#f4f4f4;color:#333;}
.alert .btn-confirm{background:#2196f3;color:#fff;}
</style>

结果悲剧了:
display:inline-block 间距bug

解决方案:(方法很多,仅列举3个常用的)
1.display:inline-block元素间不留空格
这里写图片描述

2.借助HTML注释,注释掉空格
这里写图片描述

3.简单粗暴的font-size:0也可解决;


firefox浏览器table表格边框颜色修改不了
如果是如下形式的html 和 css:

<style>
    table{border:1px solid #ddd;margin:30px auto;width:80%;text-align:center;border-collapse:collapse;}
</style>
<table border="1">
    <tr>
        <td>1</td>
        <td>2</td>
    </tr>
    <tr>
        <td>3</td>
        <td>4</td>
    </tr>
</table>

你会发现,火狐浏览器下表格的边框颜色仍然是黑色:
firefox浏览器table表格边框颜色修改不了

据上图可以看出,表格内部的样式是由td决定的,因此给td加上样式即可解决:

table td{border:1px solid #ddd;}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值