CSS技巧 (3)
2024-09-01 11:48:36
关于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元素,内联块都会堆叠在浮动块以上,看下面的层叠样式表便可知晓:
最新文章
- Spring容器初始化过程
- sql语句左右表连接理解
- [51单片机] TFT2.4彩屏3 [自制动画效果-滑块+吊钩]
- unity3d 纹理动画
- poj1651 区间dp
- 读懂 Deployment YAML - 每天5分钟玩转 Docker 容器技术(125)
- bzoj2006 [NOI2010]超级钢琴 (及其拓展)
- input file 重复上传同一张图片失效的解决办法
- 前端笔记之JavaScript(一)初识JavaScript
- eclipse总是自动跳到ThreadPoolExecutor解决办法
- event对象中 target和currentTarget 属性的区别。
- [Node.js] 08 - Web Server and REST API
- Redmine发布新闻,自动发送邮件功能失效恢复
- Java之24种设计模式-UML-模型图解读
- Android Studio自定义组合控件
- sizeof()与Marshal.SizeOf()的不同
- Vim打开文件中文乱码如何解决?
- angular5 路由传参的几种方式
- C#基础知识回顾--BackgroundWorker介绍
- django多对多数据库建立 以及数据的传输 并进行增加 删除 修改
热门文章
- React 路由&;脚手架
- HDU-4857-逃生-反向拓扑排序+优先队列
- Codeforces Round #364 (Div. 2) D. As Fast As Possible 数学二分
- Good Inflation SPOJ - GOODG 李超树
- yzoj P2343 &; 洛谷 P1437 [HNOI2004]敲砖块
- 关于JQuery.form.js异步上传文件点滴
- Linux安装yum install gcc-c++出错:Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&;arch=x86_64&;repo=os&;infra=stock error was 14: curl#6 - ";Could not resolve host: mirrorlist.centos...
- HBase数据迁移到Kafka实战
- mgo操作mongodb
- Linux 笔记 - 第十四章 LAMP 之(一) 环境搭建