CSS常用技巧

1.图片在固定宽高的容器中自适应: 

max-width: a
max-height: b
margin: 0 auto
vehicel-alin:middle

2.容器宽高自适应内容: fit-content

3. 移动端内文字是否可以被选择:

        a. user-select: none;   元素内所有文字都不可以被选择,包括 input 输入框内的文字

        b.user-select: -moz-all;子元素内所有文字都可以被选择,但是 input 输入框内的文字不可以被选择

        c.user-select: -moz-none;子元素内所有文字都不能选择,但是 input 输入框中的文字除外

4.可点击元素在 ios 上点击时,出现带颜色的背景

        -webkit-tap-highlight-color: #color

5.设置 IE 盒模型或者标准盒模型

       a. box-sizing: border-box; // IE 盒模型,宽度为 border + padding + content

        b. box-sizing: content-box;// 标准盒模型,宽度仅仅为内容宽度

6.table 中的合并边框:

        border-collapse: collapse; // 将左右上下边框合并为单一的边框

7.删除线

        text-decoration: line-through

8.下划线

        text-decoration: underline

9.Chrom 下,点击input 输入时,浏览器会自动添加边框,去掉此默认边框的解决办法

        outline:medium

10.解决移动端 iphoneX 下吸底按钮被屏幕遮挡

        

<style>
    .div {
        position: absolute;
        bottom: 0; // 一般情况下
        padding-bottom: calc(constant(safe-area-inset-bottom) + 20px); // 兼容 IphoneX
        padding-bottom: calc(env(safe-area-inset-bottom) + 20px) // 兼容 IphoneX

    }
</style>


<div class="div">
    
    <button class="btn">点击</button

</div>

11.超出省略号(...)展示

<style>
div {

    width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
</style>


<div></div>

12.元素内展示两行文字,之后空间不足,省略号展示

        

  .left{
       flex: 4;
       display: -webkit-box;
       -webkit-box-orient: vertical;
       -webkit-line-clamp: 2;
       overflow: hidden;
     }

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值