css 实现 圆角外翻 border-radius

这个示例展示了如何在Vue应用中通过JavaScript创建一个带有动态高亮效果的列表。当点击列表项时,对应的项会变为白色,并显示两个带有阴影效果的方块。点击其他项时,之前高亮的项将恢复原状,新的选中项获得高亮。此代码涉及到Vue的数据绑定、事件处理和CSS样式设计。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在这里插入图片描述

<!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>
    <script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
    <style>
      *{
        padding: 0;
        margin: 0;
      }
      .ulBox{
        width: 100px;
        height: 550px;
        background: #ccc;
      }
       li{
        height: 100px;
        width: 100%;
        list-style: none;
        z-index: 10;
      }
      .active{
        background: #fff;
        border-radius: 10px 0 0 10px;
        position: relative;
      }
      .active >  .square{
        width: 20px;
        height: 20px;
        position: absolute;
        right: 0;
        background:#fff;
      }
      .active >   .square::after{
        content: '';
        width: 100%;
        height: 100%;
        background: #ccc ;
        position: absolute;
        bottom: 0;
        right: 0;
      }
      .active >   .squareTop{
        top: -20px;
      }
      .active >  .squareBtm{
        bottom: -20px;
      }
      .active >  .squareTop::after{
        border-radius: 0 0 50% 0;
      }
      .active >  .squareBtm::after{
        border-radius: 0  50%  0  0;
      }
      
    </style>
    
  </head>
  <body>
    <div id="app">
       <ul class="ulBox">
         <li v-for="(item,index) in 5"  
         @click="change(index)" 
         :key="index" 
         :class="activeIndex == index?'active':''">
              <p class="squareTop square"></p>
              <p>{{item}}</p>
              <p class="squareBtm square"></p>
         </li>
       </ul>
    </div>

    </div>
    <script>
      var app = new Vue({
        el: '#app',
        data: {
          activeIndex:0
        },
        methods:{
          change(index){
            this.activeIndex = index
          }
        }
      });
    </script>
  </body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

web_Hsir

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值