zoukankan      html  css  js  c++  java
  • vue中用v-for循环出出来的div下面的span不给宽度也能相对于div居中

    效果图

    1.html 

    <div>          
      <div v-on:mousemove="dataDetails($event, item)" v-on:mouseleave="hiddenDetail($event)" 
      v-for="(item, index) in sectionDiagram" 
      :style="{height: item.height, left: item.sqrareLeft + 'px',  item.width + 'px',zIndex: 88 + index}" 
      :key='index' class="middleBoxBgmSquare" 
      :class="square(item.passState)">
        <span class="titleClass" >{{item.name}}</span>
      </div>
    </div>
    

    2.让span居中,外层div的position:relative

    .titleClass{
      position: absolute;
      top: -27px;
      color: #fff;
      font-size: 18px;
      word-break: keep-all;
      white-space: nowrap;
      display: inline-block;
      text-align: center;
      left: 50%;
      transform: translate(-50%,0);
    }
  • 相关阅读:
    springboot-配置文件
    system--属性
    url--web路径
    jquery--遍历
    javascript---知识点2
    iframe
    linux--磁盘挂载
    jquery--插件
    javascript窗口宽高
    vue--知识点
  • 原文地址:https://www.cnblogs.com/wgl0126/p/10874816.html
Copyright © 2011-2022 走看看