The effect we need to achieve: What is needed The styles of 1 picture, 2 pictures, and 3 pictures are different. You can use js to complete the judgment of child elements, but here I use css to complete it Core knowledge points Use CSS selectors to determine child elements example: Use CSS selector to match only one element div { &:last-child:nth-child(1) { // Related styles} } It is easy to understand: the last element under the div is also the first element, so doesn’t it have only one child element? Use CSS selector to match only two child elements div{ &:nth-last-child(2):nth-child(2) { } } Following the same pattern: The second element at the end is also the second element. Doesn’t that mean there are only two elements under this div? Finished Style HTML part <div class="box" v-for="(item,index) in list" :key="index"> <div class="header"> <img :src="item.userImage" alt=""> <span>{{item.name}}</span> </div> <div class="content"> <img :src="v" alt="" v-for="(v, i) in item.imageUrl" :key="i"> </div> <div class="bottom"> <span class="left-icon">{{item.createTime}}</span> <div class="right"> <img src="./img/6.1.png" alt=""> <span>{{item.fabulousNumber}}</span> </div> </div> </div> CSS part .box { padding: 0.26rem; .header { display: flex; align-items: center; img { width: 0.58rem; height: 0.58rem; margin-right: 0.17rem; } } .bottom { display: flex; justify-content: space-between; align-items: center; color: #999999; font-size: 0.17rem; img { width: 0.17rem; height: 0.17rem; } } .content { display: flex; margin: 0.17rem 0; img { flex: 1; height: 1.37rem; width: 0; margin-right: 0.09rem; &:last-child { margin-right: 0; } &:last-child:nth-child(1) { height: 2.75rem; } } } } The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: How to view and set the mysql time zone
>>: JavaScript to implement a simple clock
Preface Bootstrap, the most popular front-end dev...
Download the installation package from the offici...
Table of contents 1. Characteristics of JS 1.1 Mu...
This article shares the specific process of the j...
Section Course content Hours 1 Web Design Overvie...
This article uses the element official website an...
Many web designers are confused about the width of...
1. It is preferred to use the root user to log in...
Note When developing an article display list inte...
Preface This article mainly introduces the releva...
Table of contents Overview Blob Blob in Action Bl...
Alignment issues like type="radio" and t...
This tag is not part of HTML3.2 and is only suppo...
Based on the Vue image magnifier component packag...
Table of contents Preface Step 1: Setup and front...