当前位置:网站首页>8 popular recommended style layout

8 popular recommended style layout

2022-07-01 13:16:00 Justion_

home Component folder Recommend.vue

<template>
  <div class="recommend">
    <Card />
    <ul>
      <li v-for="(item, index) in RecommendList" :key="index">
        <h2>
          <img :src="item.imgUrl" alt="" />
        </h2>
        <div>
          <h3>{
   { item.name }}</h3>
          <p>{
   { item.content }}</p>
          <div class="price">
            <span>$</span>
            <b>{
   { item.price }}</b>
          </div>
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import Card from "@/components/home/Card";
export default {
  components: {
    Card,
  },
  data() {
    return {
      RecommendList: [
        {
          id: 1,
          name: " Longjing 1 iron 250G",
          content: " Fresh and mellow , Rations are preferred ",
          price: 68,
          imgUrl: "./images/h1.jpeg",
        },
        {
          id: 2,
          name: " Longjing 1 iron 250G",
          content: " Fresh and mellow , Rations are preferred ",
          price: 68,
          imgUrl: "./images/h2.jpeg",
        },
        {
          id: 3,
          name: " Longjing 1 iron 250G",
          content: " Fresh and mellow , Rations are preferred ",
          price: 68,
          imgUrl: "./images/h3.jpeg",
        },
        {
          id: 4,
          name: " Longjing 1 iron 250G",
          content: " Fresh and mellow , Rations are preferred ",
          price: 68,
          imgUrl: "./images/h4.jpeg",
        },
      ],
    };
  },
};
</script>

<style scoped>
.recommend ul li {
  position: relative;
}
.recommend ul li h2 {
  text-align: center;
}
.recommend ul li img {
  width: 9.6rem;
  height: 3.84rem;
  border-radius: 0.32rem;
}
.recommend ul li > div {
  position: absolute;
  top: 0;
  right: 0;
}
.recommend ul li > div {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  padding: 0.5333rem;
}
.recommend ul li > div h3 {
  font-size: 0.32rem;
  margin-bottom: 10px;
}
.recommend ul li > div p {
  font-size: 0.42666rem;
}
.price {
  color: red;
  text-align: right;
  margin-top: 0.5333rem;
}
</style>

newly build card Components

Using slots

The code is as follows

<template>
  <div class="">
    <div class="title">
      <slot>
        <span> Hot recommendation </span>
      </slot>
    </div>
  </div>
</template>

<script>
export default {};
</script>

<style scoped>
.title {
  text-align: center;
  font-size: 0.5rem;
  color: #333333;
}
.title span {
  position: relative;
}
.title span::before {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: block;
  background: #d4c0a7;
  top: 50%;
  margin-top: -4px;
  left: -0.5rem;
}

.title span::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: block;
  background: #d4c0a7;
  top: 50%;
  margin-top: -4px;
  right: -0.5rem;
}
</style>

The display effect is as follows :

 

原网站

版权声明
本文为[Justion_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202160025142762.html