CSS新手入门笔记整理:CSS3其他样式
warning:
这篇文章距离上次修改已过193天,其中的内容可能已经有所变动。
/* 圆角 */
.box {
border: 2px solid #000;
padding: 20px;
width: 200px;
height: 200px;
background-color: #ff0;
/* 所有角的圆角 */
border-radius: 10px;
/* 单独设置某个角的圆角 */
/* 左上角 */
border-top-left-radius: 20px;
/* 右上角 */
border-top-right-radius: 15px;
/* 右下角 */
border-bottom-right-radius: 5px;
/* 左下角 */
border-bottom-left-radius: 25px;
}
/* 盒子阴影 */
.shadowed-box {
width: 200px;
height: 200px;
background-color: #f0f;
/* 盒子阴影 */
box-shadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.75);
/* 水平偏移 垂直偏移 模糊半径 扩散半径 颜色 */
}
/* 文字阴影 */
.text-shadow {
font-size: 3em;
color: #00f;
/* 文字阴影 */
text-shadow: 2px 2px 4px #000;
}
/* 线性渐变背景 */
.linear-gradient-box {
width: 200px;
height: 200px;
/* 线性渐变背景 */
background: linear-gradient(to right, #ff0, #f0f);
/* 从左到右的渐变色 */
}
/* 径向渐变背景 */
.radial-gradient-box {
width: 200px;
height: 200px;
/* 径向渐变背景 */
background: radial-gradient(circle, #ff0, #f0f);
/* 圆形渐变 */
}
/* 自定义动画 */
@keyframes example {
from {background-color: red;}
to {background-color: yellow;}
}
/* 应用动画 */
.animated-box {
width: 200px;
height: 200px;
animation-name: example;
animation-duration: 4s;
}
/* 图片阴影 */
.image-shadow {
box-shadow: 2px 2px 4px 0px rgba(0, 0, 0, 0.5);
/* 应用于<img>元素或其他包含图像的元素 */
}
这段代码展示了如何使用CSS3中的圆角、盒子阴影、文字阴影、线性渐变、径向渐变、自定义动画和图片阴影等样式特性。每个样式都有详细的注释说明其用途和工作原理。这些是CSS3的基本特性,对于任何想要学习CSS的开发者来说都是重要的知识点。
评论已关闭