div四个角显示框

简介: 四个角显示框

div的四个角

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><TITLE> New Document </TITLE></HEAD><BODY><!-- 第一种方式 --><style>    .rect {   
    width: 100px; 
    height: 100px;
    border-radius:5px;
    background: linear-gradient(to left, #f00, #f00) left top no-repeat, 
          linear-gradient(to bottom, #f00, #f00) left top no-repeat, 
          linear-gradient(to left, #f00, #f00) right top no-repeat,
          linear-gradient(to bottom, #f00, #f00) right top no-repeat, 
          linear-gradient(to left, #f00, #f00) left bottom no-repeat,
          linear-gradient(to bottom, #f00, #f00) left bottom no-repeat,
          linear-gradient(to left, #f00, #f00) right bottom no-repeat,
          linear-gradient(to left, #f00, #f00) right bottom no-repeat;
    background-size: 5px 20px, 20px 5px, 5px 20px, 20px 5px; 
    background-color:#aaaaaa
  }
</style><divclass="rect"></div><br/><!-- 第二种方式 --><style>    .box {
        position: absolute;
      width: 100px;
      height: 100px;
      z-index:0;
      background:#eeeeee;
      overflow:hidden;
    }
    .box .box-top{
      position: absolute;
      top:0;
      width: 100%;
      height: 50%;
      z-index:1;
    }
    .box .box-top:before{
      position: absolute;
      top: 0;
      left: 0;
      content: '';
      display: block;
      height: 25%;
      width: 25%;
      border-left: 4px solid green;
      border-top: 4px solid green;
    }
    .box .box-top:after{
      position: absolute;
      top: 0;
      right: 0;
      content: '';
      display: block;
      height: 25%;
      width: 25%;
      border-right: 4px solid green;
      border-top: 4px solid green;
    }
    .box .box-upper{
      position: absolute;
      bottom:0;
      width: 100%;
      height: 50%;
      z-index:1;
    }
    .box .box-upper:before{
      position: absolute;
      bottom: 0;
      left: 0;
      content: '';
      display: block;
      height: 25%;
      width: 25%;
      border-left: 4px solid green;
      border-bottom: 4px solid green;
    }
    .box .box-upper:after{
      position: absolute;
      bottom: 0;
      right: 0;
      content: '';
      display: block;
      height: 25%;
      width: 25%;
      border-right: 4px solid green;
      border-bottom: 4px solid green;
    }
    .box .box-content{
      height: 100%;
      width: 100%;
      padding-top:40%;
      overflow:hidden;
      z-index:3;
      text-align:center;  
    }
</style><divclass="box"><divclass="box-top"></div><divclass="box-content">123</div><divclass="box-upper"></div></div></BODY></HTML>



20181227165123144.png

相关文章
|
9月前
|
前端开发 JavaScript
点击按钮,将奇数列的li背景色设置为红色,偶数列li背景色设置为绿色
点击按钮,将奇数列的li背景色设置为红色,偶数列li背景色设置为绿色
|
1月前
【推荐】实现跟随鼠标移动的浮动提示框、气泡框、Tip效果
【推荐】实现跟随鼠标移动的浮动提示框、气泡框、Tip效果
|
7月前
Echarts去掉叠堆折线区域图的区域颜色
Echarts去掉叠堆折线区域图的区域颜色
61 0
解决Echarts X轴/Y轴 坐标标签显示不下的问题
解决Echarts X轴/Y轴 坐标标签显示不下的问题 【很长的情况】
459 0
解决Echarts X轴/Y轴 坐标标签显示不下的问题
Echarts X轴 强制显示所有标签[X坐标]
Echarts X轴 强制显示所有标签[X坐标]
486 0
|
前端开发
如何用纯css实现div框四个角的点缀
用纯css实现div框四个角的点缀
836 0
关于去掉Li标签前面的小圆点和距离/显示下划线
解决方法 去掉Li标签前面的距离:     设置ul   padding:0px; 去掉Li标签前面的小圆点: 设置li      list-style-type:none; 显示下划线:    text-decoration:underline;
3057 0
div高度自适应宽度按比例放大
导语:我们经常会碰到这样的需求:要求div高度跟随宽度变化而变化。在手机端,一张图片作为div的背景图,图片宽高比不一致,并要求div宽高比与图片宽高比一致;怎么实现这种需求呢? 原理 padding-top: 50%;用这个属性的百分比,padding-top的百分比是相对于父元素的宽度,比如:...
1694 0