FormItem.vue 1.28 KB
Newer Older
姜雷 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
<template>
  <div class="FormItem">
    <div class="FormItem-label">{{label}}</div>
    <div :class="['FormItem-content', size]">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: 'form-item',
  props: {
    label: {
      type: String,
      default: '属性',
    },
    size: {
      type: String,
      default: 'normal',
    },
  },
};
</script>

<style lang="scss">
@import '../../assets/styles/variables.scss';

.FormItem {
  display: flex;
  font-size: 12px;
  color: #333;
  & + & {
    margin-left: 25px;
  }
  .FormItem-label {
    position: relative;
    width: 57px;
    text-align: justify;
    text-align-last: justify;
    &::after {
      content: ':';
      position: absolute;
      right: -5px;
    }
  }
  .FormItem-content {
    margin-left: 10px;
    &.big {
      width: 210px;
    }
    &.normal {
      width: 144px;
    }
    &small {
      width: 120px;
    }
  }
}
@media screen and (min-width: $bigScreenWidth) {
  .FormItem {
    font-size: 18px;
    & + & {
      margin-left: 40px;
    }
    .FormItem-label {
      width: 77px;
    }
    .FormItem-content {
      margin-left: 20px;
      &.big {
        width: 240px;
      }
      &.normal {
        width: 174px;
      }
      &small {
        width: 150px;
      }
    }
  }
}
</style>