CSS面试题汇总
CSS实现水平垂直居中
- margin: auto;实现绝对定位元素的居中
.center-vertical{
width: 100px;
height: 100px;
background: orange;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
- CSS3.0弹性布局
html,
body {
width: 100%;
height: 100%;
}
body {
display: flex;
align-items: center;
justify-content: center; /* 定义body的元素水平居中 */
}
.content {
width: 300px;
height: 300px;
background: orange;
}
行内元素有哪些?块级元素有哪些?
- 行内元素有:
a b span img input select strong - 块级元素有:
div ul ol li dl dt dd h1 h2 h3 h4…p - 常见的空元素:
<br> <hr> <img> <input> <link> <meta>
CSS3有哪些新特性?
- 新增各种CSS选择器 (: not(.input):)
- 圆角 (border-radius:8px)
- 多列布局 (multi-column layout)
- 阴影和反射 (Shadow\Reflect)
- 文字特效 (text-shadow)
- 文字渲染 (Text-decoration)
- 线性渐变 (gradient)
- 旋转 (transform)
- 缩放,定位,倾斜,动画,多背景
—————- END —————-
======================