美文网首页
css小技巧

css小技巧

作者: oWSQo | 来源:发表于2020-01-14 14:20 被阅读0次

利用border实现三角形和平行四边形

.test{
  width: 0;
  height: 0;
  margin: 50px;
  border-style: solid;
  border-width: 24px;
  border-color: red blue green yellow;
}

<div class="test"></div>

效果如图:

三角形的实现利用了上面的方法。

.test{
  width: 0;
  height: 0;
  margin: 50px;
  border-style: solid;
  border-width: 24px;
  border-color: red blue green yellow;
}

效果如图:

.triangle{
  position: relative;
  padding: 0 10px;
  display: inline-block;
  height: 24px;
  line-height: 24px;
  background: blue;
  color: #fff;
}
.triangle:after{
  content: '';
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 12px 6px; 
  position: absolute;
  top: 0;
  right: -12px;
  border-color: blue transparent transparent blue;
}
.triangle:before{
  position: absolute;
  display: block;
  content: '';
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 12px 6px; 
  top: 0;
  left: -12px;
  border-color: transparent blue blue transparent;
}

<div class="triangle">
    北京
</div>

效果如图:

.outer{
  display: inline-block;
  padding: 5px 20px;
  border: 1px solid blue;
  transform: skew(-20deg);
}
.inner{
  transform: skew(20deg);
}

<div class="outer">
  <div class="inner">北京</div>
</div>

效果如图:

相关文章

  • 笔记1

    1、浮动的小技巧 HTML: CSS:

  • CSS小技巧

    左右布局 左中右布局 水平居中 行内元素水平居中,在其父元素上写text-align: center;。 宽度确定...

  • css小技巧

    利用border实现三角形和平行四边形 效果如图: 三角形的实现利用了上面的方法。 效果如图: 效果如图: 效果如图:

  • css小技巧

    div高度是由什么决定的:div高度是由内部文档流中元素的高度的总和决定的 文字对齐代码: 效果图 单词中断显示:...

  • css小技巧

    最近开始写小程序然后又开始写vue真的是一个头两个大 然后慢慢记录平时的一些前端技巧不定时更新 让子元素在父控件里...

  • CSS小技巧

    1.为div[contenteditable]添加仿placeholder效果div部分 CSS部分 完事儿~

  • CSS小技巧

    1.文字超过两行,隐藏并显示省略号 overflow:hidden; text-overflow:ellips...

  • css小技巧

    1、不要写heightdiv高度 -> 文档流内容的高度和让内容撑开外面的高度 2、(1)css垂直居中table...

  • CSS小技巧

    .清除图片下方出现几像素的空白间隙方法1: 复制代码代码如下:img{display:block;}方法2: 复制...

  • CSS小技巧

    1.元素水平居中 内联元素水平居中text-align:center; 块元素水平据居中margin:0 auto...

网友评论

      本文标题:css小技巧

      本文链接:https://www.haomeiwen.com/subject/nopebftx.html