码迷,mamicode.com
首页 > Web开发 > 详细

css常用代码片段 (更新中)

时间:2020-06-14 23:22:57      阅读:85      评论:0      收藏:0      [点我收藏+]

标签:cti   cursor   ems   面试   inter   rap   image   常用   nowrap   

网上摘录常用css片段

垂直水平居中

/*绝对定位 + 未知宽高 + translate*/
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
/*flex 轻松搞定水平垂直居中(未知宽高*/
display: flex;
align-items: center;
justify-content: center;

文本末尾添加省略号

/*宽度固定,适合单行显示...*/
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
/*宽度不固定,适合多行以及移动端显示*/
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3; /*要显示的行数*/
-webkit-box-orient: vertical;

按钮粒子效果

.button {
  display: inline-block;
  padding: 1em 2em;
  background-color: #ff0081;
  color: #fff;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  position: relative;
  box-shadow: 0 2px 25px rgba(233, 30, 99, 0.5);
  outline: 0;
  transition: transform ease-in 0.1s, background-color ease-in 0.1s, box-shadow ease-in 0.25s;
}

.button::before {
  position: absolute;
  content: ‘‘;
  left: -2em;
  right: -2em;
  top: -2em;
  bottom: -2em;
  pointer-events: none;
  background-repeat: no-repeat;
  background-image: radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    /*  */
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%),
    radial-gradient(circle, #ff0081 20%, transparent 20%);
  background-position: 5% 44%, -5% 20%, 7% 5%, 23% 0%, 37% 0, 58% -2%, 80% 0%, 100% -2%, -5% 80%,
    100% 55%, 2% 100%, 23% 100%, 42% 100%, 60% 95%, 70% 96%, 100% 100%;
  background-size: 0% 0%;
  transition: background-position .5s ease-in-out, background-size .75s ease-in-out;
}

.button:active::before {
  transition: 0s;
  background-size: 10% 10%, 20% 20%, 15% 15%, 20% 20%, 18% 18%, 10% 10%, 15% 15%, 10% 10%, 18% 18%,
    15% 15%, 20% 20%, 18% 18%, 20% 20%, 15% 15%, 10% 10%, 20% 20%;
  background-position: 18% 40%, 20% 31%, 30% 30%, 40% 30%, 50% 30%, 57% 30%, 65% 30%, 80% 32%, 15% 60%,
    83% 60%, 18% 70%, 25% 70%, 41% 70%, 50% 70%, 64% 70%, 80% 71%;
}

css相关

?

104道 CSS 面试题,助你查漏补缺 - 爱前端不爱恋爱的文章 - 知乎 https://zhuanlan.zhihu.com/p/114257330

css常用代码片段 (更新中)

标签:cti   cursor   ems   面试   inter   rap   image   常用   nowrap   

原文地址:https://www.cnblogs.com/somegenki/p/13127483.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!