二、2平面转换综合案例总结

平面转换综合案例总结

案例说明:综合使用字体图标、对图片放大缩小、文本移动、渐变来完成

1.解决问题

问题1:

/* .box li:hover li .txt这样写,文字效果出不来,
因为伪类中的li与后面是父子级关系,li不能再嵌套一个li吧 */
.box li:hover .txt{
    transform: translateY(-50px);
}

问题2:

    <!-- i标签存放字体图标 -->
 <i class="iconfont icon-arrow-right "></i>

2.完整代码

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>华为新闻</title>
    <link rel="stylesheet" href="./iconfont/iconfont.css">
    <link rel="stylesheet" href="./demo.css">
</head>

<body>
    <div class="box">
        <ul>
            <li>
                <a href="#">
                    <div class="pic">
                        <img src="./images-05/product.jpeg" alt="">
                    </div>
                    <div class="txt">
                        <h4>产品</h4>
                        <h5>OceanStor Pacific 海量存储斩获2021 Interop金奖</h5>
                        <p>
                            <span>了解更多</span>
                            <!-- i标签存放字体图标 -->
                            <i class="iconfont icon-arrow-right "></i>
                        </p>
                    </div>
                    <div class="mask"></div>

                 
                </a>
            </li>
            <li>
                <a href="#">
                    <div class="pic">
                        <img src="./images-05/huawei1.jpeg" alt="">
                    </div>
                    <div class="txt">
                        <h4>行业洞察</h4>
                        <h5>迈向智能世界2030</h5>
                        <p>
                            <span>了解更多</span>
                            <i class="iconfont icon-arrow-right "></i>
                        </p>
                    </div>
                
                </a>
            </li>
            <li>
                <a href="#">
                    <div class="pic">
                        <img src="./images-05/huawei2.jpeg" alt="">
                    </div>
                    <div class="txt">
                        <h4>《ICT新视界》刊首语</h4>
                        <h5>笃行致远,共建具有获得感、幸福感、安全感的智慧城市</h5>
                        <p>
                            <span>了解更多</span>
                            <i class="iconfont icon-arrow-right "></i>
                        </p>
                    </div>
                 
                </a>
            </li>
        </ul>
    </div>
</body>

</html>
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

li {
    list-style: none;
}

a {
    text-decoration: none;
}

img {
    width: 100%;
    vertical-align: middle;

}

.box {
    width: 1110px;
    height: 247px;
    margin: 20px auto;
    /* background-color: pink; */
}

.box li {
    position: relative;
    float: left;
    width: 350px;
    height: 247px;
    margin-right: 30px;
    overflow: hidden;
}

.box li:last-child {
    margin-right: 0;
}

.box .txt {
    position: absolute;
    left: 0;
    bottom: -50px;
    width: 350px;
    height: auto;
    padding: 20px 30px;
    z-index: 1;
    color: #fff;
    transition: all .5s;
   
}

.box .txt h4 {
    font-size: 14px;
    font-weight: 400;
    line-height: 2em;
    color: #fff;
}

.box .txt h5 {
    margin-bottom: 40px;
    font-size: 18px;
    line-height: 1.5em;
    color: #fff;
}

.box .txt p {
    color: #fff;
    font-size: 14px;
}

.box .txt p .iconfont {
    color: #c7000b;
    vertical-align: middle;
    font-size: 20px;
    font-weight: 700;
}
.box  li a::after{
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 350px;
    height: 247px;
    background-image: linear-gradient(transparent,rgba(0,0,0, .6)
    );
    opacity: 0;
    transition: all .5s;
}
.box li:hover  a::after{
    opacity: 1;
}
.box li img{
    transition: all .5s;}
/* 这里a img */
.box li:hover  a img{
    transform: scale(1.2);
}
/* .box li:hover li .txt这样写,文字效果出不来,
因为伪类中的li与后面是父子级关系,li不能再嵌套一个li吧 */
.box li:hover .txt{
    transform: translateY(-50px);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值