请问如何修改。。。
来源: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>
* {
margin: 0;
padding: 0;
}
.mixed-images {
width: 100%;
height: 760px;
overflow: hidden;
}
.mixed-images .pic {
width: 25%;
height: 380px;
display: block;
float: left;
position: relative;
/* background-color: red; */
}
.mixed-images .pic .before:first-child, .mixed-images .pic .before:nth-child(2){
position: absolute;
width: 0;
height: 0;
right: 0;
margin-top: 170px;
border: 20px solid transparent;
border-right-color: #07cbc9;
}
.mixed-images .pic .before:nth-child(3),.mixed-images .pic .before:last-child {
position: absolute;
width: 0;
height: 0;
left: 0;
margin-top: 170px;
border: 20px solid transparent;
border-left-color: #07cbc9;
}
.mixed-images .pic img {
width: 100%;
height: 380px;
}
.mixed-images .word {
width: 25%;
height: 380px;
/* padding: 20px; */
float: left;
background-color: #07cbc9;
}
.mixed-images .word h3 {
color: white;
font-size: 24px;
margin-bottom: 30px;
margin-left: 20px;
margin-top: 20px;
}
.mixed-images .word .p1 {
display: block;
margin-left: 20px;
margin-bottom: 20px;
color: white;
font-size: 16px;
}
.mixed-images .word .p2 {
display: block;
margin-left: 20px;
margin-bottom: 30px;
color: gray;
font-size: 14px;
}
.mixed-images .word button {
display: block;
margin: 0 auto;
width: 138px;
height: 40px;
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回答
同学你好, before都是作为pic下的第一个子元素,无法使用:nth-child(3)和:last-child选择器选择。建议:给before添加不同的类名,设置对应的样式。
示例:第一行的两个样式相同,添加相同的类名arrow-left,第二行的两个样式相同,添加相同的类名arrow-right
通过相同的类名before设置相同的样式,然后再单独设置第一行和第二行三角形的样式和位置。
祝学习愉快~
相似问题
回答 1
回答 1