关于CSS技巧的一些题目

题目列表

所有答案点击题目链接

1、下面这个左边竖条图形,只使用一个标签,可以有多少种实现方式:

2、类似下面这样的条纹边框,只使用一个标签,可以有多少种实现方式 -- 从条纹边框的实现谈盒子模型:

技巧:

  • 利用linea-gradient 渐变

    • 缺点:IE9及以下版本不支持
  • 利用background-clip

    语法:

background-clip: border-box; // 背景延伸到边框外沿(但是在边框之下)

background-clip: padding-box; // 边框下面没有背景,即背景延伸到内边距外沿。

background-clip: content-box; // 背景裁剪到内容区 (content-box) 外沿。

  • 利用border+ouline(伪元素)
  .rect_three{
border:10px solid #9C27B0;
position:relative;
&::before{
content:"";
position:absolute;
left:0;top:0;right:0;bottom:0;
outline: dashed 10px #2196F3;
}
}
  • 利用 border+box-shadow(伪元素)

    语法:

    inset | offset-x | offset-y | color

    offset-x | offset-y | blur-radius | spread-radius | color

  .rect_four{
border:10px dashed #2196F3;
position:relative;
font-size:5px;
&::before{
position:absolute;
content:"";
top:0;bottom:0;left:0;right:0;
z-index:-1;
box-shadow: 0 0 0 10px #9C27B0;
}
}

3、层叠顺序(stacking level)与堆栈上下文(stacking context)知多少?

举个例子:

<div class="container">
<div class="inline-block">#divA display:inline-block</div>
<div class="float"> #divB float:left</div>
<!-- 或者 -->
<div class="float"> #divB float:left</div>
<div class="inline-block">#divA display:inline-block</div>
</div>

样式如下:

.container{
position:relative;
background:#ddd;
}
.container > div{
width:200px;
height:200px;
}
.float{
float:left;
background-color:deeppink;
}
.inline-block{
display:inline-block;
background-color:yellowgreen;
margin-left:-100px;
}

我们会发现 无论先生成哪个DOM元素,内联块都会堆叠在浮动块以上,看下面的层叠样式表便可知晓:

最新文章

  1. Spring容器初始化过程
  2. sql语句左右表连接理解
  3. [51单片机] TFT2.4彩屏3 [自制动画效果-滑块+吊钩]
  4. unity3d 纹理动画
  5. poj1651 区间dp
  6. 读懂 Deployment YAML - 每天5分钟玩转 Docker 容器技术(125)
  7. bzoj2006 [NOI2010]超级钢琴 (及其拓展)
  8. input file 重复上传同一张图片失效的解决办法
  9. 前端笔记之JavaScript(一)初识JavaScript
  10. eclipse总是自动跳到ThreadPoolExecutor解决办法
  11. event对象中 target和currentTarget 属性的区别。
  12. [Node.js] 08 - Web Server and REST API
  13. Redmine发布新闻,自动发送邮件功能失效恢复
  14. Java之24种设计模式-UML-模型图解读
  15. Android Studio自定义组合控件
  16. sizeof()与Marshal.SizeOf()的不同
  17. Vim打开文件中文乱码如何解决?
  18. angular5 路由传参的几种方式
  19. C#基础知识回顾--BackgroundWorker介绍
  20. django多对多数据库建立 以及数据的传输 并进行增加 删除 修改

热门文章

  1. React 路由&amp;脚手架
  2. HDU-4857-逃生-反向拓扑排序+优先队列
  3. Codeforces Round #364 (Div. 2) D. As Fast As Possible 数学二分
  4. Good Inflation SPOJ - GOODG 李超树
  5. yzoj P2343 &amp; 洛谷 P1437 [HNOI2004]敲砖块
  6. 关于JQuery.form.js异步上传文件点滴
  7. Linux安装yum install gcc-c++出错:Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&amp;arch=x86_64&amp;repo=os&amp;infra=stock error was 14: curl#6 - &quot;Could not resolve host: mirrorlist.centos...
  8. HBase数据迁移到Kafka实战
  9. mgo操作mongodb
  10. Linux 笔记 - 第十四章 LAMP 之(一) 环境搭建