当前位置:首页 > 技术文档 > 正文内容

CSS实现三角形角标以及三角形内写文字

admin6年前 (2020-09-11)技术文档2665


1.伪元素

1586339228_1_.png

//html<div class="box">
      <div class="inner-box"></div>
</div>

//css.box {
    width: 500px;
    height: 300px;   
    background-color: blue;    
    margin: 20px auto;    
    overflow: hidden;    
    .inner-box {      
        width: 0;      
        height: 0;      
        border-width: 30px 30px 0 0;      
        border-style: solid;      
        border-color: #6c6 transparent transparent transparent;
    }    
    .inner-box::after {      
        position: relative;      
        content: "已投";      
        display: block;      
        width: 30px;      
        height: 30px;      
        font-size: 2px;      
        left: 0px;      
        top: -30px;      
        transform: rotate(45deg);
    }
  }


2. 正方形旋转

NMp9FxVNl4cIw6DH.png

<div class="box1">
    <div class="inner-box1">
      <p>已投</p>
    </div>
</div>

.box1 {    
    position: relative;    
    width: 200px;    
    height: 200px;    
    background-color: orange;    
    overflow: hidden;    
    .inner-box1 {      
        width: 50%;      
        height: 50%;      
        background-color: red;      
        transform: rotate(-45deg);      
        position: absolute;      
        left: -30%;      
        top: -30%;      
        p {
            position: absolute;        
            left: 50%;        
            bottom: -15px;        
            color: #fff;        
            transform: translateX(-50%);
        }
    }
}


分享到:

扫描二维码推送至手机访问。

版权声明:本文由云河空间发布,如需转载请注明出处。

本文链接:https://www.yuyunhe.cn/index.php/post/304.html

分享给朋友:

“CSS实现三角形角标以及三角形内写文字” 的相关文章

php 获取页面内容

function get_contents($url){     if(function_exists('file_get_contents')){       &nbs...

php 使用curl模拟登录discuz以及模拟发帖

<?php $discuz_url = 'http://127.0.0.1/discuz/';//论坛地址 $login_url = $discuz_url .'logging.php?action=login...

PHP分页函数仿Google分页

/**  * 分页函数  * @param int $total    总页数  * @param int $pagesize 每页几条 &n...

php登录函数login session+mysql

<?php // 为php和mysql剔除不安全html代码。 //http://blog.ddian.cn function safestrip($string){    $string = strip_tags(...

php 获取客户端的ip、地理信息、浏览器信息、本地真实ip

<?php  // 作用取得客户端的ip、地理信息、浏览器http://blog.qita.in  class get_gust_info {        ////获得访客浏...

Zend Studio 8打开utf-8文件出现乱码解决方法

Zend Studio 8打开utf-8文件出现乱码解决方法

今天安装了zend studio 8.0.1,运行了一个PHP程序项目(项目文件编码为utf-8),发现utf-8文件中的中文全部变成乱码了,后面终于经过寻找探索,找到了问题所 在:虽然你的项目是UTF-8编码文件,但是当通过zend studio工具运行打开时,是以工具里设定的GBK编码...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。