当前位置: 首页 > news >正文

【CSS】常见

一. 溢出隐藏

1.1 单行文本溢出

.content{max-width:200px; 	/* 定义容器最大宽度 */overflow:hidden; 	/* 隐藏溢出的内容 */text-overflow:ellipsis;	/* 溢出部分...表示 */white-space: nowrap;	/* 确保文本在一行内显示 */
}

问题:display:flex 和 ellipsis 冲突
解决:把flex布局和ellipsis分别放在两个容器内

<div class="flex-content"><div class="overflow-ellipsis"><div>要展示的内容文本/数组(遍历此div)</div></div>
</div>.flex-content{display:flex;justify-content: space-between;align-items: center;
}
.overflow-ellipsis{max-width: 600px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;
}

1.2 多行文本溢出

.content{/*! autoprefixer: off */-webkit-box-orient: vertical;	/* 文本垂直排列 *//* autoprefixer: on */-webkit-line-clamp: 2;	/* 指定显示行数 */	display: -webkit-box;	/* 兼容性 盒模型 */overflow: hidden;	/* 多余部分隐藏 */
}

① /*! autoprefixer: off /和/ autoprefixer: on *是为了解决 -webkit-box-orient: vertical丢失问题
② display: -webkit-box;与overflow: hidden;一起使用来创建多行文本溢出的省略号

1.3 y轴滚动条溢出隐藏,可查看所有内容但不显示滚动条

.content{min-height: calc(73vh);		max-height: calc(80vh); /* 超过这个高度的内容会被隐藏 *//* 隐藏对应浏览器滚动条:firefox 及IE 10+ */scrollbar-width: none;-ms-overflow-style: none;overflow-y: auto; /* 自由滑动查看全部内容 */  
}.content::-webkit-scrollbar {/* Chrome Safari */display: none;	
}

二. 居中对齐

2.1 水平居中

2.1.1 width 固定,height不设
<div class="content">水平居中
</div>.content{width: 1200px; /* 百分比宽度也行,例 50% */margin: 0 auto;background-color: aqua; /*为了显示该盒子而设置的背景颜色*/
}

在这里插入图片描述

2.1.2 width不固定,height不设
<div class="content">水平居中
</div>.content{text-align:center;background-color: aqua; /*为了显示该盒子而设置的背景颜色*/
}

三. 设置图片

1.1 template中设置

<img :src="require('@/assets/award/activity-1.png')" />

1.2 style中设置

background-image: url("~@/assets/award/activity-1.png");

1.3 背景图渐变(一半白一半图)

1.1.1 单个渲染
  1. css
.backImg{background: linear-gradient(to left, rgba(255, 255, 255, 0), #fff 50%),url(~@/assets/award/activity-1.png);
}
  1. 渲染结果
    在这里插入图片描述
1.1.2 动态渲染
  1. 实现
 <div v-for="(item, index) in  AwardYearList " :key="index" :style="{background: `linear-gradient(to left, rgba(255, 255, 255, 0), #fff 40%),url(${require('@/assets/award/' + item.img)})`}">
</div>
  1. 数据
    在这里插入图片描述 3. 渲染结果
    在这里插入图片描述
http://www.lryc.cn/news/291799.html

相关文章:

  • Django实战
  • redis(1)
  • 【RTP】webrtc 学习2: webrtc对h264的rtp打包
  • 【搜索术】代码阅读理解学习笔记
  • vue 打包下载多层zip文件
  • Flink实战五_状态机制
  • SQL中having与where的区别 简单明了
  • Transformer 自然语言处理(二)
  • 软件测试之软件缺陷管理
  • 分布式锁(Distributed Lock)介绍(基于数据库(mysql);基于缓存(redis);基于ZooKeeper等分布式协调服务)
  • 10 ISIS 基础 报文 状态
  • Python第三方扩展库Matplotlib
  • 单例模式有几种写法?请谈谈你的理解?
  • 帕鲁幻兽 一键开服 简单到爆 教你10秒实现 帕鲁幻兽私服联机服务器搭建
  • 自动化报告pptx-python|如何将pandas的表格写入PPTX(二)
  • Ruby详解及安装流程
  • 免费的ChatGPT网站 ( 7个 )
  • python异步编程(1)——理论篇
  • PyTorch复现网络模型VGG
  • Springboot集成Javamelody
  • 如何将 h5 页面快速转换成微信小程序
  • 在Vue的模块开发中使用GPT的体验及总结
  • Java常见算法题解析面试题(中)
  • 提升网站性能的秘诀:为什么Nginx是高效服务器的代名词?
  • [Python图像处理] 使用OpenCV创建深度图
  • vue+element 换肤功能
  • python魔法函数[全面]
  • python实现贪吃蛇小游戏(附源码)
  • 爬虫学习笔记-Cookie登录古诗文网
  • Linux网络状态查看与防火墙管理