文字和图片垂直居中(vertical-align),图片空白缝隙,文字溢出省略号显示, 底部选择栏案例,三角符号、斜杠盒子案例272

文字和图片垂直居中(vertical-align)

在这里插入图片描述

解决图片空白缝隙

方法:
1.vertical-align
2.把图片转换为dispay:block
在这里插入图片描述

文字溢出省略号显示

1.单行文本溢出省略号显示
在这里插入图片描述

    <style>
        div{
            width: 100px;
            height: 50px;
            background-color: pink;
            margin: 100px auto;
            /* 1.文字强制一行显示 */
            white-space: nowrap;
            /* 2.隐藏溢出部分 */
            overflow: hidden;
            /* 3.溢出部分用省略号显示 */
            text-overflow: ellipsis;
        }
    </style>

2.多行文本溢出省略号显示(存在兼容性问题)
在这里插入图片描述

    <style>
        div{
            width: 100px;
            height: 50px;
            background-color: pink;
            margin: 100px auto;
            
            overflow:hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 3;
            -webkit-box-orient: vertical;
        }
    </style>

鼠标经过边框小技巧
在这里插入图片描述

            z-index: 1;

底部选择栏案例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box{
            text-align: center;
        }
        .box a,.box .enter{
            display: inline-block;
            width: 36px;
            height: 36px;
            background-color: #f7f7f7;
            border: 1px solid #cccccc;
            text-align:center;
            line-height: 36px;
            text-decoration: none;
        }
        .box .prev,.box .next{
            width: 60px;
        }
        .box .page{
            width: 10px;
            height: 20px;
        }
        .box .enter,.box .page{
            outline: none;
        }
        .box .current,.box .ele{
            background-color: #fff;
            border: none;
        }
    </style>
</head>
<body>
    <div class="box">
        <a href="#" class="prev">&lt;&lt;前一页</a>
        <a href="#" class="current">1</a>
        <a href="#">2</a>
        <a href="#">3</a>
        <a href="#" class="ele">...</a>
        <a href="#" class="next">后一页&gt;&gt;</a>
        到第<input type="text" class="page"><input type="button" value="确定" class="enter">
    </div>
</body>
</html>

在这里插入图片描述

CSS三角强化

    <style>
        .box{
            width: 0;
            height: 0;
            border-color: transparent yellow transparent transparent;
            border-style:solid;
            border-width: 100px 50px 0 0;
        }
    </style>

在这里插入图片描述

2.斜杠图标案例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .price{
            width: 200px;
            height: 30px;
            margin: 100px auto;
            text-align: center;
            line-height: 30px;
            border: 1px solid red;
        }
        .price .miaosha{
            position: relative;
            float: left;
            width: 100px;
            height: 100%;
            font-size: 16px;
            font-weight: 700;
            background-color: red;
            color: #fff;
        }
        .price .origin{
            width: 85px;
            text-decoration: line-through;
            font-size: 14px;
            color: grey;
        }
        .price .miaosha i{
            position: absolute;
            top: 0;
            right: 0;
            width: 0;
            height: 0;
            border-color: transparent white transparent transparent;
            border-style:solid;
            border-width: 30px 15px 0 0;
        }
    </style>
</head>
<body>
    <div class="price">
        <span class="miaosha">1650
            <i></i>s
        </span>
        <span class="origin">5650
        </span>
    </div>
</body>
</html>

在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值