zoukankan      html  css  js  c++  java
  • css箭头

    <div id="demo11"></div>
    
    <style>
    #demo11 {
      border: 10px solid #000;
      border-left-color: #f00;
       10px;
      height: 10px;
    }
    </style>
    

    一个三角形

    当元素宽、高为零,且其他边为透明颜色时,可以形一个三角形。

     
    <div id="demo12"></div>
    
    <style>
    #demo12 {
      border: 10px solid #000;
      border-left-color: #f00;
       0;
      height: 0;
    }
    </style>
    

    任意角度的三角形

    改变各个边的宽度,即通过调整“边框”厚度可以配置出任意角度

     
    <div id="demo14"></div>
    
    <style>
    #demo14 {
      border: 10px solid transparent;
      border-left: 20px solid #f00;
       0;
      height: 0px;
    }
    </style>
    

    通过伪元素实现

    三角形可以通过伪元素绘制出,而无需改变原来的DOM结构

    文字内容

    <span id="demo15">文字内容</span>
    
    <style>
    #demo15{
      position: relative;
    }
    #demo15:after {
      border: 10px solid transparent;
      border-left: 10px solid #f00;
       0;
      height: 0;
      position: absolute;
      content: ' '
    }
    </style>
    

    伪元素实现三角线箭头

    通过伪元素绘制出的两个,一个与背景色相同覆盖部分红色箭头,形成三角线

    文字内容

    <span id="demo15">文字内容</span>
    
    <style>
    #demo16{
      position: relative;
    }
    #demo16:after, #demo16:before {
      border: 10px solid transparent;
      border-left: 10px solid #fff;
       0;
      height: 0;
      position: absolute;
      top: 0;
      right: -20px;
      content: ' '
    }
    
    #demo16:before {
      border-left-color: #f00;
      right: -21px;
    }
    </style>
    

    三角线分割的Tab页

    • 文字内容 Tab1
    • 文字内容 Tab2
    • 文字内容 Tab3
     
    <ul id="demo17">
      <li>文字内容 Tab1</li>
      <li>文字内容 Tab2</li>
      <li>文字内容 Tab3</li>
    </ul>
    
    <style>
    #demo17{
      font-size: 10px;
      height: 24px;
    }
    
    #demo17 li {
      float: left;
      position: relative;
      list-style: none;
      margin: 0 20px 12px -19px;
      border-top: solid 1px #ddd;
      border-bottom: solid 1px #ddd;
      padding-left: 12px;
    }
    
    #demo17 li:after, #demo17 li:before {
      border: 10px solid transparent;
      border-left: 10px solid #fff;
       0;
      height: 0;
      position: absolute;
      top: 0;
      right: -18px;
      content: ' '
    }
    
    #demo17 li:before {
      border-left-color: #ddd;
      right: -19px;
    }
    </style>
    

    三角形跟矩形组合成提示框

    这里还有另一种效果,使用三角形跟矩形组合成提示框,代码来自这篇文章: Css arrows and shapes without markup

     

     

    <div id="demo"></div>
    
    <style>
    #demo {
       100px;
      height: 100px;
      background-color: #ccc;
      position: relative;
      border: 4px solid #333;
    }
    
    #demo:after, #demo:before {
      border: solid transparent;
      content: ' ';
      height: 0;
      left: 100%;
      position: absolute;
       0;
    }
    
    #demo:after {
      border- 9px;
      border-left-color: #ccc;
      top: 15px;
    }
    
    #demo:before {
      border- 14px;
      border-left-color: #333;
      top: 10px;
    }
    </style>
  • 相关阅读:
    [转]让搜索跨越语言的鸿沟—谈跨语言信息检索技术
    【PRML读书笔记-Chapter1-Introduction】1.6 Information Theory
    【PRML读书笔记-Chapter1-Introduction】1.5 Decision Theory
    [科研小记]
    【PRML读书笔记-Chapter1-Introduction】1.4 The Curse of Dimensionality
    【Machine Learning】wekaの特征选择简介
    【PRML读书笔记-Chapter1-Introduction】1.3 Model Selection
    【迁移学习】2010-A Survey on Transfer Learning
    【Machine Learning】机器学习の特征
    【PRML读书笔记-Chapter1-Introduction】1.2 Probability Theory
  • 原文地址:https://www.cnblogs.com/webgg/p/5591717.html
Copyright © 2011-2022 走看看