请问如何修改。。。

来源:2-17 自由编程

mewolmewo

2021-02-28 21:16:20

<!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>Document</title>

    <style>

        * {

            margin0;

            padding0;

        }

        .mixed-images {

            width100%;

            height760px;

            overflow: hidden;

        }

        .mixed-images .pic {

            width25%;

            height380px;

            display: block;

            float: left;

            position: relative;

            /* background-color: red; */

        }

        .mixed-images .pic .before:first-child.mixed-images .pic .before:nth-child(2){

            position: absolute;

            width0;

            height0;

            right0;

            margin-top170px;

            border20px solid transparent;

            border-right-color: #07cbc9;

        }

        .mixed-images .pic .before:nth-child(3),.mixed-images .pic .before:last-child {

            position: absolute;

            width0;

            height0;

            left0;

            margin-top170px;

            border20px solid transparent;

            border-left-color: #07cbc9;

        }

        .mixed-images .pic img {

            width100%;

            height380px;

        }

        .mixed-images .word {

            width25%;

            height380px;

            /* padding: 20px; */

            float: left;

            background-color: #07cbc9;

        }

        .mixed-images .word h3 {

            color: white;

            font-size24px;

            margin-bottom30px;

            margin-left20px;

            margin-top20px;

        }

        .mixed-images .word .p1 {

            display: block;

            margin-left20px;

            margin-bottom20px;

            color: white;

            font-size16px;

        }

        .mixed-images .word .p2 {

            display: block;

            margin-left20px;

            margin-bottom30px;

            color: gray;

            font-size14px;

        }

        .mixed-images .word button {

            display: block;

            margin0 auto;

            width138px;

            height40px;

            background: black;

            color: white;

            text-align: center;

            border: none;

        }

    </style>

</head>

<body>

    <!-- 图片混排区 -->

    <div class="mixed-images">

        <!-- <span>Faculty</span> -->

        <div class="pic">

            <div class="before"></div>

            <img src="images/b1.jpg" alt="">

        </div>

        <div class="word">

            <h3>Library</h3>

            <p class="p1">Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>

            <p class="p2">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>

            <button>EXPLORE</button>

        </div>


        <div class="pic">

            <div class="before"></div>

            <img src="images/b2.jpg" alt="">

        </div>

        <div class="word">

            <h3>Library</h3>

            <p class="p1">Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>

            <p class="p2">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>

            <button>EXPLORE</button>

        </div>


        <div class="word">

            <h3>Library</h3>

            <p class="p1">Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>

            <p class="p2">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>

            <button>EXPLORE</button>

        </div>

        <div class="pic">

            <div class="before"></div>

            <img src="images/b3.jpg" alt="">

        </div>


        <div class="word">

            <h3>Library</h3>

            <p class="p1">Lorem Ipsum is simply dummy text of the printing and typesetting industry</p>

            <p class="p2">Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>

            <button>EXPLORE</button>

        </div>

        <div class="pic">

            <div class="before"></div>

            <img src="images/b4.jpg" alt="">

        </div>

    </div>

</body>

</html>


写回答

1回答

好帮手慕慕子

2021-03-01

同学你好, before都是作为pic下的第一个子元素,无法使用:nth-child(3)和:last-child选择器选择。建议:给before添加不同的类名,设置对应的样式。

示例:第一行的两个样式相同,添加相同的类名arrow-left,第二行的两个样式相同,添加相同的类名arrow-right

http://img.mukewang.com/climg/603c47b30988111307950766.jpg

通过相同的类名before设置相同的样式,然后再单独设置第一行和第二行三角形的样式和位置。

http://img.mukewang.com/climg/603c48ad09ca7b6f06210816.jpg

祝学习愉快~

0

0 学习 · 15276 问题

查看课程