LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

纯CSS实现UI设计中常见的丝带效果

admin
2024年10月10日 20:4 本文热度 107


一、前言

网页中的丝带效果在设计中扮演着多重角色,其作用可以归纳为以下几个方面:

1. 视觉吸引与装饰

  • 增强视觉吸引力:丝带效果以其独特的形态和色彩,能够迅速吸引用户的注意力,成为页面上的视觉焦点。

  • 装饰作用:作为装饰元素,丝带能够提升网页的整体美观度,使页面看起来更加生动有趣。

2. 信息引导与层次划分

  • 信息引导:通过丝带效果的指向性设计,可以引导用户按照特定的路径浏览网页内容,提高信息的可读性和易读性。

  • 层次划分:丝带效果还可以用于区分页面上的不同区域或内容层级,帮助用户更好地理解页面结构和信息组织。

3. 风格塑造与氛围营造

  • 风格塑造:丝带元素在网页设计中常被用于塑造特定的风格,如古典老式、清新文艺、复古等,使网页呈现出独特的视觉效果。

  • 氛围营造:通过丝带的设计和色彩搭配,可以营造出不同的氛围和情感,如节日的喜庆、促销的热闹、活动的庄重等。

4. 强调与突出

  • 重点强调:丝带效果能够突出页面上的重要信息或元素,如优惠活动、新品推荐等,引导用户关注。

  • 品牌标识:在丝带设计中融入品牌元素或色彩,可以加强品牌识别度,提升品牌形象。

5. 用户体验提升

  • 增加互动性:通过CSS等技术实现的丝带效果,如折叠、展开等动态效果,可以增加用户的互动体验,提高用户的参与度和满意度。

  • 提升视觉流畅性:合理的丝带设计可以使页面看起来更加流畅和连贯,减少用户的视觉疲劳感。

在开发中遇到丝带效果,你还在让UI给你切图吗?下面就介绍几种CSS实现网页中常见的丝带效果的实现方式。

 




二、基础布局

基础布局如下:

<div class="box">

    <div class="ribbon">

        温馨提示

    </div>

</div>

.box {

    position: relative;

    width: 300px;

    height: 160px;

    margin: 60px;

    border-radius: 5px;

    background-color: #fff;

    z-index: 0;

    cursor: pointer;

    border: 1px solid #f6f6f6;

    transition: .5s;

}




三、常见丝带效果

1

.ribbon {

    position: absolute;

    left: -8px;

    top: 16px;

    width: 100px;

    height: 30px;

    background-color: #57DD43;

    /* 内容居中 */

    display: flex;

    justify-content: center;

    align-items: center;

    &::before,

    &::after {

        content: "";

        position: absolute;

    }

    &::before {

        top: -8px;

        left: 0;

        height: 0;

        width: 0;

        border-bottom: 8px solid #57DD43;

        border-left: 8px solid transparent;

        opacity: .8;

    }

    &::after {

        right: -15px;

        height: 0;

        width: 0;

        border-top: 15px solid transparent;

        border-bottom: 15px solid transparent;

        border-left: 15px solid #57DD43;

    }

} 

2

.ribbon {

    position: absolute;

    left: -10px;

    top: 16px;

    width: calc(100% + 20px);

    height: 36px;

    background-color: #1890ff;


    /* 内容居中 */

    display: flex;

    justify-content: center;

    align-items: center;


    &::before, &::after {

      content: '';

      position: absolute;

    }


    &::before {

      left: 0;

      height: 0;

      width: 0;

      border-top: 10px solid #1890ff;

      border-left: 10px solid transparent;

      bottom: -10px;

    }


    &::after {

      right: 0;

      bottom: -10px;

      height: 0;

      width: 0;

      border-top: 10px solid #1890ff;

      border-right: 10px solid transparent;

  }

}

3

<div class="box">

    <div class="ribbon">

        <span>温馨提示</span>

    </div>

</div>

.ribbon {

    position: absolute;

    top: -8px;

    right: -8px;

    width: 150px;

    height: 150px;

    overflow: hidden;

    &::before, &::after {

      content: "";

      position: absolute;

    }

    &::before {

      left: 8px;

      width: 40px;

      height: 8px;

      border-radius: 8px 8px 0px 0px;

      background-color: var(--ribbon-primary-color);

      opacity: .6;

    }

    &::after {

      border-radius: 0px 8px 8px 0px;

      width: 8px;

      height: 40px;

      right: 0px;

      bottom: 8px;

      background-color: #57DD43;

      opacity: .6;

    }

    & > span {

      position: absolute;

      top: 20%;

      right: -40%;

      z-index: 2;

      width: 150%;

      height: 40px;

      overflow: hidden;

      transform: rotate(45deg);

      border: 1px dashed;

      box-shadow: 0 0 0 3px #57DD43, 0px 21px 5px -18px rgba(0, 0, 0, 0.6);

      background: #57DD43;

      /* 文本居中 */

      display: flex;

      justify-content: center;

      align-items: center;

      color: white;

    }

}

4

.ribbon {

    position: absolute;

    top: -6px;

    left: 16px;

    width: 40px;

    padding: 0 10px;

    box-sizing: border-box;

    text-align: center;

    background: #ff9900;

    &::before,

    &::after {

        content: '';

        position: absolute;

    }

    &::before {

        top: 0;

        right: -6px;

        height: 0;

        width: 0;

        border-bottom: 6px solid #ff9900;

        border-right: 6px solid transparent;

        opacity: .8;

    }

    &::after {

        height: 0;

        width: 0;

        left: 0;

        bottom: -20px;

        border-left: 20px solid #ff9900;

        border-right: 20px solid #ff9900;

        border-bottom: 20px solid transparent;

    }

}

5

.ribbon {

    position: absolute;

    top: 14px;

    left: -5px;

    padding: 2px 10px;

    background-color: orangered;

   

    color: #fff;

    &::before {

        content: "";

        position: absolute;

        left: 0;

        bottom: -4px;

        border-top: 4px solid orangered;

        border-left: 4px solid transparent;

    }

}

.ribbon {

    position: absolute;

    top: 10%;

    right: -5px;

    padding: 2px 10px;

    background-color: orangered;

   

    color: #fff;

    &::before {

        content: "";

        position: absolute;

        right: 0;

        bottom: -4px;

        border-top: 4px solid orangered;

        border-right: 4px solid transparent;

    }

}

6

<div class="box">

    <div class="ribbon">

        <span>温馨提示</span>

    </div>

</div>

.ribbon {

    position: absolute;

    top: -6px;

    right: 10px;

    &::after {

        content: "";

        display: block;

        position: absolute;

        width: 0;

        height: 0;

        border-left: 53px solid transparent;

        border-right: 53px solid transparent;

        border-top: 10px solid #57DD43;

    }

    &>span {

        position: relative;

        display: inline-block;

        width: 90px;

        height: 60px;

        line-height: 60px;

        text-align: center;

        background: #57DD43;

        border-top-right-radius: 8px;

        &::before,

        &::after {

            content: "";

            position: absolute;

        }

        &::before {

            left: -6px;

            top: 0;

            width: 6px;

            height: 6px;

            background: #57DD43;

        }

        &::after {

            left: -8px;

            top: 0;

            width: 8px;

            height: 6px;

            border-radius: 8px 8px 0 0;

            background: #57DD43;

        }

    }

}

7

<div class="box">

    <div class="ribbon">

        <span>新品</span>

    </div>

</div>

.ribbon {

    position: absolute;

    top: 0;

    right: 0;

    width: 45px;

    height: 45px;

    background: #57DD43;

    clip-path: polygon(0 0, 100% 100%, 100% 0);

    span {

       

        position: absolute;

        top: 6px;

        right: 2px;

        display: inline-block;

        transform: rotate(45deg)

    }

}

<div class="box">

    <div class="ribbon">

        <span>新品</span>

    </div>

</div>

.ribbon {

    position: absolute;

    top: 0;

    left: 0;

    width: 45px;

    height: 45px;

    background: #57DD43;

    clip-path: polygon(0 0, 0 100%, 100% 0);

    span {

       

        position: absolute;

        top: 6px;

        right: 16px;

        display: inline-block;

        transform: rotate(-45deg)

    }

}

网页中的丝带效果在视觉吸引、信息引导、风格塑造、强调与突出以及用户体验提升等方面都发挥着重要作用。设计师在运用丝带效果时,应根据网页的整体风格和设计需求进行灵活搭配和创新设计,以达到最佳的视觉效果和用户体验。


该文章在 2024/10/11 9:30:07 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved