自适应 panel 小 demo

html(宽度是百分比):
<div class="panel-out">
  <div class="panel-main">
    <div class="logo-content">

    </div>
    <div class="panel-content">

    </div>
  </div>
</div>
css:
CSS  margin padding 属性的垂直方向的百分比值都是相对于宽度计算的
.panel-out {
  padding: 10px;
  border-bottom: 1px solid rgb(236, 236, 236);
  box-sizing: border-box;
  background-color: white;
}

.panel-main {
  position: relative;
  padding-left: 25%;
  padding-bottom: 25%;
  border: 1px solid red;
}

.logo-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 25%;
  height: 100%;
  background-color: lightgray;
}

.panel-content {
  position: absolute;
  top: 0;
  right: 0;
  width: 75%;
  height: 100%;
  background-color: gray;
}


panel-vue 组件(宽度是固定的数值):
<template>
    <div class="panel-out">
        <div class="panel-main">
            <div class="user-avatar-panel" :style="{'background-image':'url('+ avatar +')'}"></div>
            <div class="info-content">
                <div class="long-text">{{name}}</div>
                <div class="company long-text">{{company}}</div>
                <!-- <div v-if="desc" class="company long-text">{{desc}}</div> -->
            </div>
        </div>
        <div v-if="desc" class="desc">{{desc}}</div>
    </div>
</template>

<script>

    export default {
        name: "user-info-panel",
        props: ['name', 'company', 'desc', 'avatar'],
        data() {
            return {
            };
        },
        computed: {},
        methods: {},
        components: {}
    }
</script>

<style scoped>
    .panel-out {
        /* height: 100px; */
        padding: 10px;
        border-bottom: 1px solid rgb(236, 236, 236);
        box-sizing: border-box;
        background-color: white;
    }

    .panel-main {
        position: relative;
        padding-left: 60px;
    }

    .user-avatar-panel {
        position: absolute;
        top: 0;
        left: 0;
        width: 60px;
        height: 60px;
        background-position: center;
        background-size: cover;
        border-radius: 50%;
    }

    .info-content {
        height: 60px;        
        box-sizing: border-box;
        margin-left: 5%;
    }

    .info-content div{
        line-height: 30px;
    }

    .company {
        color: rgb(148, 143, 143);
        font-size: 15px;
    }
    .long-text{
        text-overflow: ellipsis;
        white-space: nowrap;
        overflow: hidden;
    }
    .desc{
        color: rgb(148, 143, 143);        
    }
</style>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值