03-css3新特性

CSS3 的新增特性有很多,以下是其中的一些:

响应式布局 中的媒体查询(media query)和弹性盒子(flexbox)可以让创建响应式和灵活的布局。

媒体查询:

.container {

  max-width: 600px;

  margin: 0 auto;

}

@media (max-width: 600px) {

  .container {

    font-size: 36px;

  }

}

弹性盒子:

.container {

  display: flex;

  flex-wrap: wrap;

  justify-content: space-between;

}

.item {

  flex: 1;

  padding: 20px;

  border: 1px solid #ccc;

}

渐变和阴影 中的渐变和阴影可以让元素具有更丰富的视觉效果。

渐变:

.gradient {

  background-color: lightblue;

  height: 100px;

  width: 100%;

}

.gradient2 {

  background-color: blue;

  height: 50%;

  width: 50%;

}

.gradient3 {

  background-color: red;

  height: 50%;

  width: 50%;

}

阴影:

.shadow {

  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);

}

过渡和动画 中的 transition 和 animation 可以让元素具有更丰富的交互效果。

过渡:

动画:


.animate {

  animation: fadeInOut 0.5s ease forwards;

}

@keyframes fadeInOut {

  from {

    opacity: 0;

  }

  to {

    opacity: 1;

  }

}

存储空间和响应式单位 中的 box-sizing 和 font-size 属性可以让元素具有更丰富的响应式特性。

box-sizing:

.container {

  max-width: 600px;

  margin: 0 auto;

}

.item {

  flex: 1;

  padding: 20px;

  border: 1px solid #ccc;

}

font-size:



.container {

  max-width: 600px;

  margin: 0 auto;

}

h1 {

  font-size: 32px;

}

这些是 CSS3 新增的一些特性,可以帮助创建更加灵活、响应式的网页。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值