震惊,加上这css动画,产品经理直呼溜溜溜
波浪扩展动画 /* css动画 */ @-webkit-keyframes ball-scale-multiple { 0% { -webkit-transform: scale(0); transform: scale(0); opacity: 0; } 5% { opacity: 1; } 100% { -webkit-transform: scale(1); transform: scale(1); opacity: 0; } } @keyframes ball-scale-multiple { 0% { -webkit-transform: scale(0); transform: scale(0); opacity: 0; } 5% { opacity: 1; } 100% { -webkit-transform: scale(1); transform: scale(1); opacity: 0; } } .ball-scale-multiple { position: relative; -webkit-transform: translate(0.2rem,0.14rem); -ms-transform: translate(0.2rem,0.14rem); transform: translate(0.2rem,0.14rem); z-index: 1; } .ball-scale-multiple>div:nth-child(2) { -webkit-animation-delay: 0.2s; animation-delay: 0.2s; } .ball-scale-multiple>div:nth-child(3) { -webkit-animation-delay: 0.4s; animation-delay: 0.4s; } .ball-scale-multiple>div { background-color: rgb(191, 235, 205); width: .15rem; height: .15rem; border-radius: 100%; -webkit-animation-fill-mode: both; animation-fill-mode: both; position: absolute; right: 0rem; top: -0.54rem; opacity: 0; margin: 0; width: .8rem; height: .8rem; -webkit-animation: ball-scale-multiple 1s 0s linear infinite; animation: ball-scale-multiple 1s 0s linear infinite; }光标移动动画@keyframes colorRight { 0% { background-position: -100% 0; } 100% { background-position: 130% 0; } } li:hover { p:first-child { animation: colorRight 1.2s; color: #222; background: @fontColor linear-gradient( -135deg, transparent 25%, transparent 40%, rgba(255, 255, 255, 1) 40%, rgba(255, 255, 255, 1) 60%, transparent 60%, transparent ); background-size: 20px 20px; background-repeat: no-repeat; -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-position: -100% 0; } }边框闪动@keyframes borderRotate { 50% { height: 100%; width: 0; } 100% { height: 100%; width: 100%; } } li:hover { &::before { content: ""; position: absolute; width: 0; height: 0; border-left: 1px solid #98acff; border-bottom: 1px solid #98acff; z-index: 6; left: 0; bottom: 0; animation: borderRotate 0.5s forwards; } &::after { content: ""; position: absolute; width: 0; height: 0; border-top: 1px solid #98acff; border-right: 1px solid #98acff; z-index: 6; right: 0; top: 0; animation: borderRotate 0.5s forwards; } }
查看详情点赞评论收藏浏览822023-03-01 10:27:21css 限制显示行数,超出部分加上...(兼容IE)
在我们日常前端开发中,经常会遇到列表或者首页文本只显示几行等问题。一般我们通过css 就可以解决。代码:/*一行文本超出显示省略号*/ .one-line { overflow: hidden; white-space: nowrap; display: block; -o-text-overflow: ellipsis; text-overflow: ellipsis; } /*多行文本超出显示省略号*/ .two-line { overflow: hidden; -o-text-overflow: ellipsis; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; /* 可以显示的行数,超出部分用...表示*/ -webkit-box-orient: vertical; }但是在IE中有兼容问题,虽然现在很少再兼容IE了。有兴趣的同学可以了解下。兼容IE // 处理多行文本超出部分隐藏 function wordLimit(cName, wordLength) { var cName = document.getElementsByClassName(cName); for (var i = 0; i < cName.length; i++) { var nowHtml = cName[i].innerHTML; var nowLength = cName[i].innerHTML.length; if ( nowLength > wordLength) { cName[i].innerHTML = nowHtml.substr(0, wordLength) + '…'; } } };
查看详情点赞评论收藏浏览572023-03-10 21:45:21CSS 弹性盒 Flex用法
首先什么是Flex呢?Flex是Flexible Box的缩写,意为”弹性布局”,用来为盒状模型提供最大的灵活性。相较于Flex布局,就是传统的盒模型布局了。我们常用的盒模型布局有,display布局,float浮动布局,position定位布局,传统盒模型布局和弹性布局都能解决我们前端开发中的常见布局问题,但是盒模型在处理某些布局就显得特别不方便了。比如,垂直居中问题。Flex:display:flex;首先所有的HTML元素都适用于弹性布局,元素设为弹性布局之后,子元素的float、clear和vertical-align属性将失效。容器和项目容器:采用Flex布局的元素,称为Flex容器(flex container),简称”容器”;项目:“容器”的所有子元素自动成为容器成员,称为Flex项目(flex item),简称”项目”;容器默认存在两根轴:水平的主轴(main axis 从左至右)和垂直的交叉轴(cross axis 从上至下)。主轴的开始位置(与边框的交叉点)叫做main start,结束位置叫做main end;交叉轴的开始位置叫做cross start,结束位置叫做cross end。弹性盒Flex容器属性,即父元素上的属性首先父元素启用弹性盒布局:display:flex;flex-directionflex-wrapflex-flowjustify-contentalign-itemsalign-content1、flex-directionflex-direction:设置主轴的方向。row: (默认值)主轴为水平方向,起点在左端,从左至右排列; row-reverse:主轴为水平方向,起点在右端,从右至左排列; column:主轴为垂直方向,起点在上沿,从上至下排列; column-reverse:主轴为垂直方向,起点在下沿,从下至上排列。nowrap:(默认值)不换行; wrap:换行,第一行在上方; wrap-reverse:换行,第一行在下方。3、flex-flow是flex-direction属性和flex-wrap属性的简写形式,默认值为row nowrap4、justify-contentjustify-content:设置主轴上的子元素对齐方式。它可能取5个值,具体对齐方式与轴的方向有关。下面假设主轴为从左到右:flex-start:(默认值),左对齐(沿着主轴开始位置至末尾位置对齐); flex-end:右对齐(沿着主轴末尾位置至开始位置对齐); center:居中对齐; space-around:每个项目两侧的间隔相等。所以,项目之间的间隔比项目与边框的间隔大一倍; space-between: 两端对齐,项目之间的间隔都相等。 5、align-items定义项目在交叉轴上如何对齐。flex-start:交叉轴的起点对齐; flex-end:交叉轴的终点对齐; center:交叉轴的中点对齐(可以理解为垂直居中); baseline:项目的第一行文字的基线对齐; stretch:(默认值),如果项目未设置高度或设为auto,将占满整个容器的高度。6、align-content上面提到过align-items适用于子元素在单行中使用,这个align-content则就是为了子元素多行的时候设置交叉轴的子元素的排列方式。flex-start:与交叉轴的起点对齐; flex-end:与交叉轴的终点对齐; center:与交叉轴的中点对齐; space-around:根轴线两侧的间隔都相等。所以,轴线之间的间隔比轴线与边框的间隔大一倍; space-between:与交叉轴两端对齐,轴线之间的间隔平均分布; stretch:(默认值),占满整个交叉轴。 项目上的元素属性(即子元素)orderflex-growflex-shrinkflex-basisflexalign-self1、orderorder属性定义项目的排列顺序。数值越小,排列越靠前,默认为0。2、flex-growflex-grow属性定义项目的放大比例,默认为0,即如果存在剩余空间,也不放大。.box div { flex-grow: 1 }: 值都为1,则它们将等分剩余空间3、flex-shrinkflex-shrink属性定义了项目的缩小比例,默认为1,即如果空间不足,该项目将缩小。4、flex-basisflex-basis属性定义了在分配多余空间之前,项目占据的主轴空间(main size)。浏览器根据这个属性,计算主轴是否有多余空间。它的默认值为auto,即项目的本来大小。它可以设为跟width或height属性一样的值(比如350px),则项目将占据固定空间flex-basis: auto | 350px;5、flexflex属性是flex-grow, flex-shrink 和 flex-basis的合写,默认值为0 1 auto。后两个属性可选。6、align-selfalign-self属性允许单个项目有与其他项目不一样的对齐方式,可覆盖align-items属性。默认值为auto,表示继承父元素的align-items属性,如果没有父元素,则等同于stretch。align-self: auto | flex-start | flex-end | center | baseline | stretch;举例:多行布局<style> *{ padding:0; margin: 0; } html,body{ width: 100%; height: 100%; } .box{ width: 640px; background: rgb(243, 171, 171); height: 640px; display: flex; flex-wrap: wrap; align-content: space-between; justify-content: space-between; } .boxSon{ background: yellow; width: 200px; height: 200px; } </style> <body> <div class="box"> <div class="boxSon">1</div> <div class="boxSon">2</div> <div class="boxSon">3</div> <div class="boxSon">4</div> <div class="boxSon">5</div> <div class="boxSon">6</div> <div class="boxSon">7</div> <div class="boxSon">8</div> <div class="boxSon">9</div> </div> </body>差不多就到这儿了。
查看详情点赞评论收藏浏览392023-03-26 10:02:04