border的特殊用法
大家很容易在一些网页上看到二级菜单上有一个小的三角形,这个小三角型 除了可以使用图片或者使用iconfont写出来,还可以使用border写出来
这边简单的为大家举一个例子,希望对大家有用吧!
css样式为:
*{
margin:0;
padding:0;
}
.box{
position: relative;
margin:100px 400px;
animation: move1 4s linear infinite;
}
.box div{
/*opacity: 0.6;*/
}
.box1{
border-left:200px solid red;
border-right:200px solid transparent;
border-bottom:200px solid transparent;
content:" ";
width:0;
height:0;
}
.box2{
border-left:200px solid transparent;
border-right:200px solid yellow;
border-bottom:200px solid transparent;
content:" ";
width:0;
height:0;
position: absolute;
top:0;
}
.box3{
border-left:200px solid transparent;
border-right:200px solid green;
border-bottom:200px solid transparent;
content:" ";
width:0;
height:0;
transform: translateX(-200px);
transform: rotate(180deg);
}
.box4{
border-left:200px solid transparent;
border-right:200px solid palevioletred;
border-bottom:200px solid transparent;
content:" ";
width:0;
height:0;
position: absolute;
top:100px;
left: 100px;
transform: rotate(90deg);
}
.box5{
border-left:200px solid blueviolet;
border-right:200px solid transparent;
border-bottom:200px solid transparent;
content:" ";
width:0;
height:0;
position: absolute;
top:-100px;
left: 100px;
transform: rotate(-90deg);
}
.box6{
border-left:200px solid transparent;
border-right:200px solid yellowgreen;
border-bottom:200px solid transparent;
content:" ";
width:0;
height:0;
position: absolute;
left: -200px;
top:200px;
}
.box7{
border-left:200px solid red;
border-right:200px solid transparent;
border-bottom:200px solid transparent;
content:" ";
width:0;
height:0;
position: absolute;
top:200px;
left: 200px;
}
.box8{
border-left:200px solid transparent;
border-right:200px solid blue;
border-bottom:200px solid transparent;
content:" ";
width:0;
height:0;
position: absolute;
top:-100px;
left:-100px;
transform: rotate(90deg);
}
.boxt{
position: relative;
top:-400px;
animation: move 2s linear infinite;
}
@keyframes move {
from {
transform-origin: 200px 200px;
transform: rotate(0);
}
to {
transform-origin: 200px 200px;
transform: rotate(360deg);
}
}
@keyframes move1 {
from {
transform-origin: 200px 200px;
transform: rotate(360deg) scale(1);
}
to {
transform-origin: 200px 200px;
transform:rotate(0) scale(1.5);
}
}
html样式为:
<div class="box">
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
<div class="boxt">
<div class="box5"></div>
<div class="box6"></div>
<div class="box7"></div>
<div class="box8"></div>
</div>
</div>
虽然这里我举例的并不是二级菜单上的小三角,但是你只要明白了这个原理,二级菜单上的小三角直接用border和定位就可以写出来了!
border的特殊用法的更多相关文章
- border透明
最近在写一表项目,需要边框透明,起初我以为没有办法实现,最近看一本书中找到办法,就是通过rgba实现,代码如下: border: 1px solid rgba(0, 0, 0, 0.7); 关于rgb ...
- 12个你未必知道的CSS小知识
虽然CSS并不是一种很复杂的技术,但就算你是一个使用CSS多年的高手,仍然会有很多CSS用法/属性/属性值你从来没使用过,甚至从来没听说过. 1.CSS的color属性并非只能用于文本显示 对于CSS ...
- 【HTML+CSS】(1)基本语法
HTML基金会 <em>他强调标签,<strong>加粗标签 <q>短文本引用.<blockquote>长文本引用,这两个标签会让文字带双引號. 空 ...
- 每日分享!介绍Css 盒模型!
如何定义盒模型: 在CSS盒子模型理论中,页面中所有的元素都是看成一个盒子,并且还占据一定的空间. 一个页面是由很多这样的盒子组成的.这些盒子之间都会相会影响,因此我们掌握CSS盒模型相当重要.需要理 ...
- WEB入门.六 盒子模型
学习内容 CSS盒子模型 盒子之间的关系 页面元素定位 能力目标 理解盒子模型 理解内容与表现分离的优点 理解并掌握盒子之间的关系 理解并掌握绝对定位与相对定位的用法 本章简介 上一章节中已经讲解了页 ...
- [置顶] Silverlight之控件应用总结(一)(3)
[置顶] Silverlight之控件应用总结(一)(3) 分类: 技术2012-04-02 20:35 2442人阅读 评论(1) 收藏 举报 silverlightradiobuttondatat ...
- padding(内边框), border(边框), margin, 标准文档流, 块级元素和行内元素, 浮动 ,margin的用法
盒模型 在CSS中,"box model"这一术语是用来设计和布局时使用,然后在网页中基本上都会显示一些方方正正的盒子.我们称为这种盒子叫盒模型. 盒模型有两种:标准模型和IE模型 ...
- WPFのBorder的用法
border介绍: 下面是StackPanel中,一个简单的,具有轻微圆角的边框,围绕在一组按钮外面: <Border Margin="5" Padding="5& ...
- css样式之border
border用法详解: 1.border-width 属性设置边框的宽度 可能的值:像素 2.border-style 属性设置边框的样式 可能的值:solid(直线),dashed(虚线),dott ...
随机推荐
- GregorianCalendar公里类
使用GregorianCalendar 获得日期是年中第几周第几天 public class Common { /// <summary> /// 获取日期是年中的第几周 /// < ...
- angular validation 使用总结
我由于制作登陆界面,用到了angular-validation,结合ng-cookies,实现记住账户密码的功能.文档是https://github.com/hueitan/angular-valid ...
- Flink - Asynchronous I/O
https://docs.google.com/document/d/1Lr9UYXEz6s6R_3PWg3bZQLF3upGaNEkc0rQCFSzaYDI/edit // create the ...
- mysql学习【第1篇】:初识MySQL
狂神声明 : 文章均为自己的学习笔记 , 转载一定注明出处 ; 编辑不易 , 防君子不防小人~共勉 ! mysql学习[第1篇]:初识MySQL 只会写代码的是码农:学好数据库,基本能混口饭吃:在此基 ...
- Linux下MySql的配置文件my.cnf详细 讲解
经常在使用MySql,但是对于MySql下面的各种参数的配置并不是很熟悉,经常在需要改变某项参数的时候,还要到处在网上查找,有点不方便.今天想把MySql下面的配置文件my.cnf详细的做一个说明(L ...
- xca自签发证书解决chrome浏览器证书不可信问题记录
xca打开的界面 依次File, New DataBase,选择xdb文件保存路径,再输入密码 切换到Certificates页面,点击New Certificate 出现如下界面 因为要创建根证书, ...
- 在Java程序中读写windows共享文件夹
摘要 使用Java通过JCIFS框架读写共享文件夹,使用SMB协议,并支持域认证. 项目常常需要有访问共享文件夹的需求,例如读取共享文件夹存储的视频.照片和PPT等文件.那么如何使用Java读写Win ...
- 安装 Samba服务
参考摘录的是博客园的文章:https://www.cnblogs.com/zhaopengcheng/p/5481048.html ubuntu系统:16.04 1. 首先用管理员权限创建一个新用户, ...
- Python 字符串常用方法总结
明确:对字符串的操作方法都不会改变原来字符串的值 1,去掉空格和特殊符号 name.strip() 去掉空格和换行符 name.strip('xx') 去掉某个字符串 name.lstrip() ...
- es分词器
1.默认的分词器 standard standard tokenizer:以单词边界进行切分standard token filter:什么都不做lowercase token filter:将所有字 ...