代码之家  ›  专栏  ›  技术社区  ›  steerr

如何通过CSS去除色带边框?

  •  0
  • steerr  · 技术社区  · 6 年前

    我正在尝试使用Bootstrap 4在div周围创建一个ribbon。

    我无法清理正确的边界;在移动设备上,当页面缩小时,我的功能区溢出到右侧,脱离父div: https://jsfiddle.net/auj4q3a2/

    Html:

    <div class="container-fluid">
    
        <div class="card profile-card">  
            <div class="container-fluid">
                <div class="row user-social-detail">
                    <div class="col-lg-12 col-sm-12 col-12">
                        <a href="#"><i class="fa fa-facebook" aria-hidden="true"></i></a>
                        <a href="#"><i class="fa fa-twitter" aria-hidden="true"></i></a>
                        <a href="#"><i class="fa fa-instagram" aria-hidden="true"></i></a>
                        <a href="#"><i class="fa fa-linkedin" aria-hidden="true"></i></a>
                    </div>
                </div>
            </div>
        </div>
    
    </div>
    

    CSS:

    .profile-card {
        box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
        max-width: 475px;
        margin: auto;
        text-align: center;
    }
    
    .user-social-detail{
        margin: 0 -30px;
        padding: 15px 0px;
        background-color: #ffd280;
        border-radius: 4px;
    }
    .user-social-detail a i{
        color:#fff;
        font-size:23px;
        padding: 0px 5px;
    }
    .user-social-detail::before,
    .user-social-detail::after {
      content: '';
      position: absolute;
      z-index: -1;
      left: -45px;
      top: -28px;
      display: block;
      width: 40px;
      height: 0px;
      border: 30px solid transparent;
      border-right: 20px solid #e5bd73;
      border-bottom-color: transparent;
      border-left-color: transparent;
    }
    
    .user-social-detail::after {
      left: auto;
      right: -45px;
      border-left: 20px solid #e5bd73;
      border-right: 30px solid transparent;
    }
    

    如何将ribbon装入mobile上的容器(如左侧)?

    欢迎您提出任何建议或反馈,我们将不胜感激。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Damián Pablo González    6 年前

    明白了!

    你必须加上

    overflow-x: hidden !important; .container-fluid

    编辑: 事实上,只有第一名。容器流体这是必要的,因此您可以将以下内容添加到CSS文件中:

    .container-fluid:first-of-type {
        overflow-x: hidden !important;
    }