美文网首页
css 想啥写啥

css 想啥写啥

作者: 王康_Wang | 来源:发表于2017-02-28 17:16 被阅读0次

字母大小写

  • text-transform 值:
    capitalize 英文拼音的首字母大写
    uppercase 英文拼音字母全大写
    lowercase 英文拼音字母全小写

文字超出省略号

  • text-overflow 值:
    clip:不显示省略标记(...),而是简单的裁切;
    ellipsis:当对象内文本溢出时显示省略标记(...)。

css 过渡和动画

    transition-delay: 1s;
    transition-duration: 2s;
    transition-property: height;
    transition-timing-function: ease;
    transition: 1s 2s height ease;

animation
animation 可以帮我们实现复杂的动画,使用animation我们首先要定义动画过程,也就是关键帧

  @keyframes rainbow {
    0% { background: #coo; }
    50% { background: orange; }
    100% { background: yellowgreen; }
  }

绑定动画

div:hover {
  animation: 1s raindow;
}

当鼠标悬停在div元素上时,会产生名为rainbow的动画效果,持续时间为哦1s,动画只播放一次。加入infinite关键字,可以让动画无限次播放;

div:hover {
  animation: 1s rainbow infinite;
}

也可以指定动画播放次数,比如3次:

div:hover {
 animation: 1s ranibow 3;
}

animation-fill-mode
动画结束以后,会立即从结束状态跳回到起始状态。如果想让动画保持在结束状态,需要使用animation-fill-mode属性。

div:hover {
  animation: 1s rainbow forwards;
}

animation-fill-mode可以使用下列值

  • none:默认值,回到动画没开始时的状态
  • forwards:让动画停留在结束状态
  • backwards:让动画回到第一帧的状态
  • both: 根据animation-direction(见后)轮流应用forwards和backwards规则

animation-direction
动画循环播放时,每次都是从结束状态跳回到起始状态,在开始播放。animation-direction属性,可以改变这种行为

animation-direction

简写:

  div:hover {
    animation: 1s 2s rainbow infinite forwards alternate ;
  }

分写:

  div:hover {
    animation-duration: 1s;
    animation-delay: 2s;
    animation-name: rainbow;
    animation-timing-function: linear; /* ease */
    animation-iteration-count: 3;      /* infinte */
    animation-fill-mode:forwards;      /* none forwards backwards both */
    animation-direction: normal;       /* normal reverse alternate alternate-reverse */
  }

垂直水平居中

<style>
  html,body {
    position: relative;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
  }
  div {
    position: absolute;
    width: 50%:
    height: 50%;
    transform: translate(-50%,50%);
    background-color: #333;
  }
</style>

或者用负margin也行。

自适应固定宽高比

  html,body {
    position: relative;
    padding: 0;
    margin: 0;
    width: 100%;
    height: 100%;
  }
 .img-ct {
   width: 50%;
   height: 0;
   padding-bottom: 25%;  // 父元素宽度的25%,宽高比2:1
  } 

相关文章

  • css 想啥写啥

    字母大小写 text-transform 值:capitalize 英文拼音的首字母大写uppercase 英文拼...

  • 想啥写啥

    又到了日更的时候,今天去上了考研英语课,已经有两次没去了。听课比上次强多了,起码没有瞌睡。 两次没去感觉还是落下好...

  • 想啥写啥

    这段时间参加超星里的四大名知识竞赛,本以为自己知道的很多,四大名著里的《红楼梦》看过多遍,电视剧也看过三...

  • 想啥写啥

    这周,通宵了一次,本来是5点回宿舍打算直接睡的,结果一不小心发现返校季是当天开始的,只能再熬一熬,熬到七点,买了平...

  • 想写啥就写啥

    当你写不出来时,就从一堆费话开始吧。 开始吧, 对,写点啥呢? 写了这么久,我还不知道自己写作的风格是啥样子。我只...

  • 想写啥就写啥

    1对于亲子与夫妻关系,总想指出对方是错的,就证明自己是对的,特别是亲子关系中,以大欺小的感觉,说话语气喜欢大声,好...

  • 心里想啥写啥

    每次我对朋友的用心,我自己都被自己感动的稀里哗啦的,可能他们也会感动,但是反过来却没有一个人像我对他(她)们那样对...

  • 心里想啥写啥

    每次我对朋友的用心,我自己都被自己感动的稀里哗啦的,可能他们也会感动,但是反过来却没有一个人像我对他(她)们那样对...

  • 2017-09-18

    写字就写字,让加啥图片,我想写啥就写啥

  • 想啥写啥好快乐

    中午好呀!最近可能比较闲,也不知咋回事,可能着实是因为比较闲哈哈哈! 发现一到晚上就特别清醒,也不是清醒,乱七八糟...

网友评论

      本文标题:css 想啥写啥

      本文链接:https://www.haomeiwen.com/subject/umaxgttx.html