flex布局防止被挤压 flex-shrink: 0

本文探讨了在使用Flex布局时遇到的两个常见问题:文本溢出容器和固定宽高图片被压缩。针对这些问题,文章提供了详细的代码示例和解决策略,包括设置子容器宽度为0、使用overflow:hidden以及给图片设置flex-shrink:0属性。

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

lex布局非常好用,但在开发过程中可能会碰到的一些坑

1、内容超出容器
大致情况是:在一个设置了display:flex布局的大容器A中并排放置两个子容器,并且子容器设置flex:1,子容器中都有一个元素包含一段文本,这段文本设置了不换行并且显示省略号的样式,当文本过长的时候,子容器会被撑开,如下效果:

 

相关代码:

<view class='hot-content-box'>
<view wx:for="{{hotCollageList}}" wx:key="hci" class='hot-item-box' data-goodsid="{{item.goodsId}}" data-activityid="{{item.activityId}}" bindtap="goodsDetail">
<image src='{{item.goodsPic}}' mode='widthFix'></image>
<view class='goods-name'>{{item.goodsName}}</view>
<view class="goods-num">{{item.rule.numLimit}}人团</view>
<view class="goods-price-box">
<view class="goods-act-price goods-line">¥{{item.actualPrice}}</view>
<view class="goods-price-txt goods-line">拼团价</view>
<view class="goods-org-price goods-line">¥{{item.goodsPrice}}</view>
</view>
</view>
</view>
.hot-content-box {
padding: 0 30rpx 30rpx;
background: #fff;
display: flex;
}

.hot-item-box {
padding: 20rpx;
box-shadow: inset 0 -1px 1px 1px rgba(228, 221, 221, 0.50);
border-radius: 8px;
flex: 1;
}
.hot-item-box:first-child{
margin-right: 30rpx;
}
.goods-name {
font-size: 18px;
color: #000;
letter-spacing: 0.72px;
line-height: 22px;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
这里的text-overflow: ellipsis;不生效,省略号没有出现,并且过长的文字将子容器撑开,问题可能出在于子容器没有设置宽度,省略符可能需要对父元素设置宽度,设置为100%无效,当设置为0的时候,省略号出现了

.hot-item-box {
padding: 20rpx;
box-shadow: inset 0 -1px 1px 1px rgba(228, 221, 221, 0.50);
border-radius: 8px;
flex: 1;
width: 0;
}


因为不设置宽度,子容器会被文本节点无限撑开,通过测试发现,设置子容器overflow:hidden也可以满足效果。

这里参考:https://blog.youkuaiyun.com/zgh0711/article/details/78270555

2、设置了固定宽高的图片被压缩
通常实现如下的效果,是把外层容器设置为display:flex,容器中图片设置固定宽高度,右边元素设置为flex:1,但当右边元素宽度超出剩余空间的时候,图片会被挤压,变成椭圆形。

 

这是因为在flex容器中,当空间不够的时候,flex-shrink不为0的元素会被压缩,所以解决的方法就是给图片设置:flex-shrink:0。

.existCollages .row image {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 8px;
flex-shrink: 0;/*防止被压缩*/
}

转载于:https://www.cnblogs.com/zzsdream/p/10437920.html

<template> <view class="container"> <!-- 搜索表单区域 --> <view class="search-card"> <view class="form-group title-group"> <text class="form-label">问卷标题:</text> <input v-model="formData.dcWjTitle" placeholder="请输入问卷标题" class="form-input title-input" /> </view> <view class="form-row"> <!-- 被测评人选择器 --> <view class="form-group form-group-half"> <text class="form-label">被测评人:</text> <view class="search-select-container"> <view class="input-container" @click="showBdrList = true"> <!-- 已选项显示 --> <view v-if="formData.dcId.length > 0" class="selected-display"> {{ selectedBdrLabel }} </view> <!-- 占位符 --> <text v-else-if="showBdrPlaceholder" class="placeholder-text"> 请选择被测评人 </text> <!-- 下拉箭头 --> <view class="dropdown-icon"> <text>▼</text> </view> </view> <!-- 下拉列表 --> <view v-if="showBdrList" class="dropdown-list"> <view class="search-box"> <input v-model="bdrSearchKeyword" placeholder="搜索被测评人" class="search-input" @input="filterBdrOptions" /> </view> <scroll-view scroll-y="true" class="dropdown-scroll"> <view v-for="(item, index) in filteredBdrOptions" :key="index" class="dropdown-item" :class="{ 'selected': formData.dcId[0] === item.value }" @click="handleBdrSelect(item)" > {{ item.label }} </view> <view v-if="filteredBdrOptions.length === 0" class="empty-option"> 无匹配结果 </view> </scroll-view> </view> <!-- 遮罩层 --> <view v-if="showBdrList" class="dropdown-mask" @click="showBdrList = false" ></view> </view> </view> <!-- 人员部门 --> <view class="form-group form-group-half"> <text class="form-label">人员部门:</text> <input v-model="formData.dcDept" placeholder="请输入部门" class="form-input" /> </view> </view> <!-- 提交状态和按钮组 --> <view class="form-row-bottom"> <!-- 提交状态 --> <view class="state-group"> <text class="form-label">提交状态:</text> <view class="search-select-container"> <view class="state-select-box" @click="toggleStateList"> <text class="selected-state"> {{ getStateLabel(formData.state) }} </text> <view class="dropdown-icon"> <text>▼</text> </view> </view> <!-- 状态下拉列表 --> <view v-if="showStateList" class="dropdown-list state-dropdown"> <view v-for="(state, index) in stateOptions" :key="index" class="dropdown-item" :class="{ 'selected': formData.state === state.value }" @click="handleStateSelect(state)" > {{ state.label }} </view> </view> <!-- 遮罩层 --> <view v-if="showStateList" class="dropdown-mask" @click="showStateList = false" ></view> </view> </view> <!-- 按钮组 --> <view class="button-group"> <button class="search-button" @click="handleSearch">搜索</button> <button class="reset-button" @click="handleReset">重置</button> </view> </view> </view> <!-- 数据显示区域 --> <view class="data-card"> <view class="card-header"> <button class="refresh-button" @click="refreshData">刷新数据</button> </view> <!-- 加载状态 --> <view v-if="loading" class="loading-container"> <view class="loading-spinner"></view> <text class="loading-text">加载中...</text> </view> <!-- 数据展示 --> <view v-else> <view v-for="(item, index) in surveyList" :key="index" class="data-card-item" > <view class="card-header-section"> <view class="card-title">{{ item.dcWjTitle }}</view> </view> <view class="card-body-section"> <view class="card-row"> <text class="card-label">被测评人:</text> <text class="card-value">{{ item.dcName }}</text> </view> <view class="card-row"> <text class="card-label">部门:</text> <text class="card-value">{{ item.dcDept }}</text> </view> <view class="card-row"> <text class="card-label">创建时间:</text> <text class="card-value">{{ item.createTime }}</text> </view> <view class="card-row"> <text class="card-label">提交时间:</text> <text class="card-value">{{ item.updateTime || '-' }}</text> </view> </view> <view class="card-footer-section"> <view class="status-container"> <view :class="[ 'status-tag', item.state === '1' ? 'status-submitted' : 'status-not-submitted' ]" > {{ item.state === '1' ? '已提交' : '未提交' }} </view> <view class="score">总分: {{ item.score || '0' }}</view> </view> <button class="view-button" @click="handleView(item)">编辑/查看</button> </view> </view> <!-- 空数据提示 --> <view v-if="surveyList.length === 0" class="empty"> <text>暂无数据</text> </view> </view> <!-- 分页控件 --> <view v-if="surveyList.length > 0" class="pagination-container"> <picker mode="selector" :range="[5, 10, 20, 50]" :value="[5, 10, 20, 50].indexOf(pagination.size)" @change="handleSizeChange" class="page-size-picker" > <view class="picker"> 每页 {{ pagination.size }} 条 </view> </picker> <view class="pagination-buttons"> <button :disabled="pagination.current === 1" @click="handlePageChange(pagination.current - 1)" class="page-button prev-button" > 上一页 </button> <text class="page-info"> 第 {{ pagination.current }} 页 / 共 {{ Math.ceil(pagination.total / pagination.size) }} 页 </text> <button :disabled="pagination.current >= Math.ceil(pagination.total / pagination.size)" @click="handlePageChange(pagination.current + 1)" class="page-button next-button" > 下一页 </button> </view> <text class="total-records">共 {{ pagination.total }} 条记录</text> </view> </view> </view> </template> <style scoped> .container { padding: 20rpx; background-color: #f5f5f5; min-height: 100vh; } /* 卷标题*/ .title-group { display: flex; align-items: center; gap: 20rpx; } /* 表单布局优化 */ .form-row { display: flex; flex-wrap: wrap; gap: 20rpx; margin-bottom: 20rpx; } .form-group { margin-bottom: 25rpx; width: 100%; } .form-group-half { flex: 1; min-width: 300rpx; } .form-label { font-size: 28rpx; color: #606266; font-weight: 500; white-space: nowrap; flex-shrink: 0; /* 防止标签被压缩 */ } .title-input { flex: 1; /* 输入框占据剩余空间 */ min-width: 0; /* 防止溢出 */ } .form-input { width: 100%; height: 80rpx; padding: 0 20rpx; border: 1px solid #dcdfe6; border-radius: 8rpx; font-size: 28rpx; background-color: #fff; box-sizing: border-box; } /* 搜索卡片优化 */ .search-card { background: #fff; border-radius: 16rpx; padding: 25rpx; margin-bottom: 25rpx; box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.05); } .button-group { display: flex; gap: 15rpx; flex-shrink: 0; } .search-button, .reset-button { width: 150rpx; height: 80rpx; line-height: 80rpx; font-size: 28rpx; border-radius: 8rpx; text-align: center; border: none; padding: 0; margin: 0; box-sizing: border-box; } /* 按钮悬停效果 */ .search-button:hover, .reset-button:hover { opacity: 0.9; transform: translateY(-2rpx); } .search-button:active, .reset-button:active { opacity: 1; transform: translateY(0); } .search-button { background-color: #409eff; color: #fff; } .reset-button { background-color: #f5f7fa; color: #606266; border: 1px solid #dcdfe6; } /* 被测评人选择器优化 */ .search-select-container { position: relative; width: 100%; } .input-container { position: relative; width: 100%; height: 80rpx; padding: 0 60rpx 0 20rpx; border: 1px solid #dcdfe6; border-radius: 8rpx; background-color: #fff; display: flex; align-items: center; box-sizing: border-box; } .selected-display { color: #303133; font-size: 28rpx; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; } .placeholder-text { color: #c0c4cc; font-size: 28rpx; flex: 1; } .dropdown-icon { position: absolute; right: 20rpx; top: 50%; transform: translateY(-50%); font-size: 24rpx; color: #606266; } .dropdown-list { position: absolute; top: 100%; left: 0; right: 0; max-height: 400rpx; background: #fff; border: 1px solid #dcdfe6; border-radius: 8rpx; z-index: 1000; box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.1); margin-top: 8rpx; } .search-box { padding: 15rpx; border-bottom: 1px solid #f0f2f5; } .search-input { width: 100%; height: 70rpx; padding: 0 20rpx; border: 1px solid #dcdfe6; border-radius: 8rpx; font-size: 28rpx; background-color: #f5f7fa; box-sizing: border-box; } .dropdown-scroll { max-height: 300rpx; } .dropdown-item { padding: 20rpx; font-size: 28rpx; color: #333; border-bottom: 1px solid #f0f2f5; } .dropdown-item.selected { background-color: #f5f7fa; color: #409eff; font-weight: 500; } .dropdown-item:last-child { border-bottom: none; } .dropdown-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: transparent; z-index: 999; } .empty-option { padding: 20rpx; text-align: center; color: #999; font-size: 28rpx; } /* 状态选择器优化 */ .state-select-box { position: relative; width: 100%; height: 80rpx; padding: 0 60rpx 0 20rpx; border: 1px solid #dcdfe6; border-radius: 8rpx; font-size: 28rpx; background-color: #fff; display: flex; align-items: center; box-sizing: border-box; } .selected-state { color: #303133; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .state-dropdown { max-height: 300rpx; } /* 数据卡片优化 */ .data-card { background: #fff; border-radius: 16rpx; padding: 25rpx; box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.05); } .card-header { margin-bottom: 25rpx; } .refresh-button { background-color: #409eff; color: #fff; height: 70rpx; line-height: 70rpx; font-size: 28rpx; border-radius: 8rpx; border: none; } .data-card-item { background: #fff; border-radius: 12rpx; padding: 25rpx; margin-bottom: 25rpx; box-shadow: 0 2rpx 6rpx rgba(0,0,0,0.03); border: 1px solid #ebeef5; } .card-header-section { padding-bottom: 15rpx; border-bottom: 1px solid #f0f2f5; margin-bottom: 15rpx; } .card-title { font-size: 32rpx; font-weight: bold; color: #303133; line-height: 1.4; word-break: break-word; } .card-body-section { margin-bottom: 15rpx; } .card-row { display: flex; margin-bottom: 12rpx; font-size: 28rpx; } .card-label { color: #606266; width: 150rpx; flex-shrink: 0; } .card-value { color: #303133; flex: 1; word-break: break-word; } .card-footer-section { display: flex; justify-content: space-between; align-items: center; padding-top: 15rpx; border-top: 1px solid #f0f2f5; } .status-container { display: flex; align-items: center; gap: 15rpx; } .status-tag { padding: 6rpx 18rpx; border-radius: 40rpx; font-size: 24rpx; font-weight: 500; } .status-submitted { background-color: #f0f9eb; color: #67c23a; border: 1px solid #e1f3d8; } .status-not-submitted { background-color: #fef0f0; color: #f56c6c; border: 1px solid #fde2e2; } .score { font-size: 28rpx; color: #e6a23c; font-weight: 500; } .view-button { background-color: #409eff; color: #fff; height: 60rpx; line-height: 60rpx; padding: 0 25rpx; font-size: 26rpx; border-radius: 40rpx; border: none; } /* 分页样式优化 */ .pagination-container { margin-top: 30rpx; display: flex; flex-direction: column; align-items: center; gap: 15rpx; } .page-size-picker { width: 200rpx; height: 60rpx; border: 1px solid #dcdfe6; border-radius: 8rpx; text-align: center; line-height: 60rpx; font-size: 26rpx; background: #fff; } .pagination-buttons { display: flex; align-items: center; gap: 15rpx; } .page-button { height: 60rpx; line-height: 60rpx; padding: 0 25rpx; font-size: 26rpx; border-radius: 8rpx; background-color: #f5f7fa; color: #606266; border: 1px solid #dcdfe6; } .page-button:disabled { opacity: 0.5; background-color: #fafafa; } .page-info { font-size: 26rpx; color: #606266; } .total-records { font-size: 26rpx; color: #909399; } /* 加载状态样式 */ .loading-container { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 80rpx 0; } .loading-spinner { width: 70rpx; height: 70rpx; border: 6rpx solid #f3f3f3; border-top: 6rpx solid #3498db; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 25rpx; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } .loading-text { color: #666; font-size: 28rpx; } /* 空数据提示 */ .empty { text-align: center; padding: 80rpx 0; color: #999; font-size: 30rpx; } .form-row-bottom { display: flex; align-items: center; justify-content: space-between; gap: 20rpx; margin-top: 10rpx; } .state-group { flex: 1; display: flex; align-items: center; gap: 15rpx; } </style> 我想要编辑/查看按钮靠右
最新发布
07-26
<script lang="ts" setup> import { ref, onMounted, nextTick } from 'vue' import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus' import { useRouter } from 'vue-router' import request from '@/utils/request' import type { ResultModel } from '@/api/model/model' // 类型定义 interface PasswordForm { oldPassword: string newPassword: string confirmPassword: string } interface LoginUser { id: number username: string // 增加用户名字段 name: string role: string } // API调用(修改参数结构) const updatePasswordApi = (data: { username: string; password: string; newPassword: string }) => request.put<any, ResultModel>('/emps/update', data) const router = useRouter() const loginName = ref('管理员') const loginRole = ref('管理员') const username = ref('') // 存储用户名 const showPasswordDialog = ref(false) const passwordForm = ref<PasswordForm>({ oldPassword: '', newPassword: '', confirmPassword: '', }) const passwordFormRef = ref<FormInstance>() const loading = ref(false) // 密码验证规则 const passwordRules: FormRules<PasswordForm> = { oldPassword: [ { required: true, message: '请输入旧密码', trigger: 'blur' }, { min: 6, max: 20, message: '密码长度6-20个字符', trigger: 'blur' }, ], newPassword: [ { required: true, message: '请输入新密码', trigger: 'blur' }, { min: 6, max: 20, message: '密码长度6-20个字符', trigger: 'blur' }, { validator: (_, value, callback) => { if (value === passwordForm.value.oldPassword) { callback(new Error('新密码能与旧密码相同')) } else { callback() } }, trigger: 'blur', }, ], confirmPassword: [ { required: true, message: '请确认新密码', trigger: 'blur' }, { validator: (_, value, callback) => { if (value !== passwordForm.value.newPassword) { callback(new Error('两次输入的密码一致')) } else { callback() } }, trigger: 'blur', }, ], } // 初始化用户信息(增加用户名获取) onMounted(() => { const token = localStorage.getItem('token') if (token) { try { const loginUser: LoginUser = JSON.parse(token) loginName.value = loginUser.name || '管理员' loginRole.value = loginUser.role || '管理员' username.value = loginUser.username || '' // 获取用户名 } catch (e) { console.error('解析token失败:', e) } } }) // 打开修改密码对话框(保持变) const openPasswordDialog = () => { showPasswordDialog.value = true passwordForm.value = { oldPassword: '', newPassword: '', confirmPassword: '' } nextTick(() => { if (passwordFormRef.value) { passwordFormRef.value.resetFields() } }) } // 提交修改密码(调整跳转逻辑) const submitPassword = async () => { if (!passwordFormRef.value) return try { await passwordFormRef.value.validate() loading.value = true const response = await updatePasswordApi({ username: username.value, password: passwordForm.value.oldPassword, newPassword: passwordForm.value.newPassword, }) if (response.code === 1) { ElMessage.success('密码修改成功,请重新登录') showPasswordDialog.value = false passwordFormRef.value.resetFields() // 直接跳转到登录页面,显示退出确认 localStorage.removeItem('token') router.push('/login') } else { ElMessage.error(response.msg || '密码修改失败') } } catch (error) { console.error('修改密码失败:', error) ElMessage.error('请求失败,请稍后重试') } finally { loading.value = false } } // 修改退出登录方法(保持原有的确认提示) const logout = () => { ElMessageBox.confirm('确定要退出登录吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', center: true, }) .then(() => { localStorage.removeItem('token') router.push('/login') ElMessage.success('退出登录成功') }) .catch(() => {}) } </script> <template> <div class="common-layout"> <el-container class="layout-container"> <!-- 优化后的头部 --> <el-header class="header"> <div class="header-content"> <div class="logo-section"> <div class="logo"></div> <span class="title">AI教学管理系统</span> </div> <div class="user-section"> <div class="user-info"> <el-avatar class="user-avatar" :size="36"> {{ loginName.charAt(0) }} </el-avatar> <div class="user-details"> <div class="user-name">{{ loginName }}</div> <div class="user-role">{{ loginRole }}</div> </div> </div> <div class="header-tools"> <el-tooltip content="修改密码" placement="bottom"> <el-button class="tool-btn" type="text" @click="openPasswordDialog"> <el-icon class="icon"><EditPen /></el-icon> </el-button> </el-tooltip> <el-tooltip content="退出登录" placement="bottom"> <el-button class="tool-btn" type="text" @click="logout"> <el-icon class="icon"><SwitchButton /></el-icon> </el-button> </el-tooltip> </div> </div> </div> </el-header> <el-container class="main-container"> <!-- 侧边栏 --> <el-aside class="aside"> <el-scrollbar class="menu-scrollbar"> <el-menu router default-active="/index" class="side-menu" background-color="#2c3e50" text-color="#ecf0f1" active-text-color="#f39c12" > <el-menu-item index="/index"> <el-icon><Menu /></el-icon> <span>首页</span> </el-menu-item> <el-sub-menu index="2" class="menu-group"> <template #title> <el-icon><Document /></el-icon> <span>班级学员管理</span> </template> <el-menu-item index="/stu"> <el-icon><UserFilled /></el-icon> <span>学员管理</span> </el-menu-item> <el-menu-item index="/clazz"> <el-icon><HomeFilled /></el-icon> <span>班级管理</span> </el-menu-item> </el-sub-menu> <el-sub-menu index="3" class="menu-group"> <template #title> <el-icon><Avatar /></el-icon> <span>部门管理</span> </template> <el-menu-item index="/emp"> <el-icon><Avatar /></el-icon> <span>员工管理</span> </el-menu-item> <el-menu-item index="/dept"> <el-icon><HelpFilled /></el-icon> <span>部门管理</span> </el-menu-item> </el-sub-menu> <el-sub-menu index="4" class="menu-group"> <template #title> <el-icon><PieChart /></el-icon> <span>数据统计管理</span> </template> <el-menu-item index="/report/emp"> <el-icon><InfoFilled /></el-icon> <span>员工信息统计</span> </el-menu-item> <el-menu-item index="/report/stu"> <el-icon><Share /></el-icon> <span>学员信息统计</span> </el-menu-item> <el-menu-item index="/log"> <el-icon><Clock /></el-icon> <span>日志信息统计</span> </el-menu-item> </el-sub-menu> </el-menu> </el-scrollbar> </el-aside> <!-- 主内容区 --> <el-main class="main-content"> <router-view></router-view> </el-main> </el-container> </el-container> <!-- 修改密码对话框 --> <el-dialog v-model="showPasswordDialog" title="修改密码" width="500px" center :close-on-click-modal="false" > <el-form ref="passwordFormRef" :model="passwordForm" :rules="passwordRules" label-width="100px" label-position="right" > <el-form-item label="旧密码" prop="oldPassword"> <el-input v-model="passwordForm.oldPassword" type="password" placeholder="请输入当前密码" show-password clearable /> </el-form-item> <el-form-item label="新密码" prop="newPassword"> <el-input v-model="passwordForm.newPassword" type="password" placeholder="6-20位字符" show-password clearable /> </el-form-item> <el-form-item label="确认密码" prop="confirmPassword"> <el-input v-model="passwordForm.confirmPassword" type="password" placeholder="请再次输入新密码" show-password clearable /> </el-form-item> </el-form> <template #footer> <div class="dialog-footer"> <el-button @click="showPasswordDialog = false">取消</el-button> <el-button type="primary" @click="submitPassword" :loading="loading"> 确认修改 </el-button> </div> </template> </el-dialog> </div> </template> <style scoped> /* 布局基础样式 */ .common-layout { height: 100vh; display: flex; flex-direction: column; background-color: #f5f7fa; } .layout-container { height: 100%; display: flex; flex-direction: column; } /* 头部样式 - 优化版 */ .header { background: linear-gradient(135deg, #2c3e50 0%, #1a2530 100%); color: white; height: 64px; padding: 0; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); z-index: 1000; position: relative; } .header-content { display: flex; justify-content: space-between; align-items: center; height: 100%; padding: 0 30px; max-width: 1600px; margin: 0 auto; width: 100%; } .logo-section { display: flex; align-items: center; gap: 15px; } .logo { width: 40px; height: 40px; background: linear-gradient(135deg, #3498db, #8e44ad); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; font-weight: bold; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); } .title { font-size: 1.8rem; font-weight: 700; letter-spacing: 1px; background: linear-gradient(to right, #f39c12, #f1c40f); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); } .user-section { display: flex; align-items: center; gap: 20px; } .user-info { display: flex; align-items: center; gap: 12px; padding: 5px 15px; border-radius: 30px; background: rgba(255, 255, 255, 0.1); transition: all 0.3s ease; } .user-info:hover { background: rgba(255, 255, 255, 0.15); } .user-avatar { background: linear-gradient(135deg, #3498db, #8e44ad); display: flex; align-items: center; justify-content: center; font-weight: bold; color: white; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); } .user-details { display: flex; flex-direction: column; } .user-name { font-weight: 600; font-size: 15px; letter-spacing: 0.5px; } .user-role { font-size: 12px; color: #bdc3c7; margin-top: 2px; } .header-tools { display: flex; gap: 8px; } .tool-btn { color: #ecf0f1; font-size: 18px; padding: 8px; transition: all 0.3s ease; border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; } .tool-btn:hover { background-color: rgba(255, 255, 255, 0.15); transform: translateY(-2px); } .tool-btn .icon { transition: transform 0.3s ease; } .tool-btn:hover .icon { transform: scale(1.2); } /* 侧边栏样式 */ .aside { background-color: #2c3e50; color: #ecf0f1; height: 100%; width: 240px !important; transition: width 0.3s ease; border-right: 1px solid #34495e; } .menu-scrollbar { height: calc(100vh - 64px); } .menu-scrollbar .el-scrollbar__bar.is-vertical { width: 6px; right: 2px; border-radius: 4px; background-color: rgba(255, 255, 255, 0.1); } .menu-scrollbar .el-scrollbar__thumb { background-color: rgba(255, 255, 255, 0.3); border-radius: 4px; transition: background-color 0.3s ease; } .menu-scrollbar .el-scrollbar__thumb:hover { background-color: rgba(255, 255, 255, 0.5); } .side-menu { background-color: transparent; border-right: none; padding: 15px 0; } .side-menu .el-menu-item, .side-menu .el-sub-menu .el-sub-menu__title { margin: 6px 10px; padding: 12px 20px; font-size: 14px; color: #ecf0f1; border-radius: 6px; transition: all 0.3s ease; height: 48px; display: flex; align-items: center; } .side-menu .el-menu-item:hover, .side-menu .el-sub-menu .el-sub-menu__title:hover { background-color: #34495e; transform: translateX(5px); } .side-menu .el-menu-item.is-active { background: linear-gradient(90deg, rgba(52, 152, 219, 0.3), transparent); color: #f39c12 !important; font-weight: bold; border-left: 3px solid #f39c12; } .menu-group .el-menu-item { font-size: 13px; padding-left: 50px !important; color: #dcdcdc; transition: all 0.3s ease; height: 42px; } .menu-group .el-menu-item:hover { background-color: #3a5267; transform: translateX(5px); } .menu-group .el-menu-item.is-active { background-color: #3a5267; color: #f1c40f; font-weight: 600; } /* 主内容区样式 */ .main-content { background-color: #f0f2f5; padding: 20px; flex: 1; overflow-y: auto; border-radius: 8px 8px 0 0; box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.05); } /* 对话框样式 */ .dialog-footer { display: flex; justify-content: center; padding: 10px 20px 0; } /* 响应式设计 */ @media (max-width: 992px) { .aside { width: 200px !important; } .header-content { padding: 0 20px; } .title { font-size: 1.5rem; } .user-info .user-name { display: none; } } @media (max-width: 768px) { .aside { width: 64px !important; } .logo-section .title, .user-info .user-details, .el-sub-menu .el-sub-menu__title span, .el-menu-item span { display: none; } .el-sub-menu .el-sub-menu__title, .el-menu-item { justify-content: center; padding: 0 !important; } .el-icon { margin-right: 0 !important; font-size: 20px; } .menu-group .el-menu-item { padding-left: 20px !important; justify-content: flex-start; } } </style> 优化一下页面自适应大小,页面缩小之后右上角的退出登录会被挡住
07-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值