鍍金池/ 問答/HTML/ vue遍歷出來的數(shù)據(jù)用同樣的樣式展示出現(xiàn)錯位

vue遍歷出來的數(shù)據(jù)用同樣的樣式展示出現(xiàn)錯位

clipboard.png

<template>
  <div>
     <div class = "foods-wrapper">
      <div class="fooList" v-for="(item,index) in goods">
        <div v-for="food in item.foods" v-show="name==item.name" class = 'food'>
          <span>{{food.name}}</span>
          <span>¥{{food.price}}</span>
   
          </div>
      </div>
    </div>
  <div class="navMenu">
    <ul>
       <li v-for="(item,index) in goods" :class="isSelected == index?'navMenu-selected':'nav'" @click = 'menuClick(item.name,index)'>
          <span class="text">
            
            {{item.name}}
          </span>
        </li>
    </ul>
    
  </div>
 
 </div>
</template>

<script>
import axios from 'axios'
import Vue from 'vue'
export default {
  name: 'navMenu',
   created() {
    axios.get('static/data.json').then((res) => {
      console.log(res.data.goods)
      this.goods = res.data.goods
      
    });
  },
  data() {
    return {
      goods: [],
      isSelected:0,
      name:'food',
      selectedFood: '',
    }
  },
  computed:{
    // selectFoods() {
    //   let foods = []
    //   this.goods.forEach((good) => {
    //     good.foods.forEach((food) => {
    //       if (food.count) {
    //         foods.push(food)
    //       }
    //     })
    //   })
    //   return foods
    // }
  },

  methods:{
    menuClick (name,index) {
    this.isSelected = index 
    this.name=name
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.navMenu{
 position: fixed;
 right: 1%;
 top:0;
 height: 100%;
 color:white;

}
.navMenu ul{
  list-style: none;
  background: #00B595;
  padding: 5%;

}
.navMenu ul li{
  margin:20% 0% 10%;
  padding: 5%;

}
.nav{

  list-style: none;
  background: #00B595;
  padding: 5%;
  margin:20% 0% 10%;
  padding: 5%;

}
.navMenu-selected{
  background: #00725E;
}
.foods-wrapper{
  background: #DBE0E3;
  position: absolute;
  top:3%;
  left:30%;
  width:60%;
  height:80%;
}
.foodList{
margin: 1%;

}
.food{
  background-color: #FFFFFF;
  border-radius: 8%;
  display: inline-block;
  height:90px;
  width:125px;
  margin: 1%;
}
</style>

樣式都一樣的 為什么會出現(xiàn)這種情況

回答
編輯回答
朕略萌

因為框里的文字行數(shù)不一 瀏覽器默認的baseline是根據(jù)文本基準線排列的
方案 框框全部加上vertical-align:top

2018年9月15日 19:58