【问题标题】:How to put a border-radius on a specific corner of a button如何在按钮的特定角上放置边框半径
【发布时间】:2017-12-08 10:49:45
【问题描述】:

我有一个看起来像这样的模式

如您所见,模态框有边框半径,但页脚处的按钮没有。我想在紫色按钮的左下角放置一个边框半径,在灰色按钮的右下角放置一个边框半径。我试过border-bottom-left-radius和border-bottom-right-radius,但它没有用。这是我的代码

模态:

<!--Notifier Modal-->
<div id="notifier-modal" class="modal fade" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
   <div class="modal-dialog modal-md" role="document">
       <div class="modal-content">
           <div class="modal-body">
               <div class="row">
                   <div class="col-md-12">
                       <div class="confirm-purchase-label">
                           Only {{size}} out of {{totalsize}} transactions have been loaded <br>
                           <h5>The complete list of transactions will be sent to your email after the process.</h5>
                       </div>
                   </div>
               </div>
           </div>

           <div class="modal-footer g-nopadding">
               <div class="col-md-6 g-nopadding">
                   <button type="button" class="btn btn-purple btn-block col-md-6" ng-click="proceedAction();">PROCEED</button>
               </div>
               <div class="col-md-6 g-nopadding">
                   <button type="button" class="btn btn-gray btn-block col-md-6" data-dismiss="modal">CANCEL</button>
               </div>
           </div>
       </div>
   </div>

CSS:

#notifier-modal .btn,
{
    border: none!important;
    border-radius: 0px!important;
    font-family: 'AvenirMedium';
    height: 50px!important;
}

#notifier-modal .modal-md{
    width: 500px;
}

.modal-footer {
   padding: 15px;
   text-align: right;
   border-top: 1px solid #e5e5e5;
}

.modal-content{
   background:#f0f0f0;
   box-shadow:0px 0px 30px 0px rgba(101,101,101,0.50);
   border: none;
}

.btn-gray {
   color: #797979!important;
   background:#e0e0e0!important;
   font-size:14px!important;
   border: none!important;
}   

.btn-purple {
   color: #f0f0f0!important;
   background-color: #9c82cd!important;
   font-size:14px!important;
   border: none!important;
}

【问题讨论】:

  • 您可以尝试在模态页脚中添加左下角和右下角的边框半径。
  • 对我没用

标签: html css bootstrap-modal


【解决方案1】:
.modal-footer{
   border-bottom-left-radius: 5px; 
   border-bottom-right-radius: 5px; 
   overflow: hidden;
}

overflow: hidden 解决了。

【讨论】:

    【解决方案2】:

    您可以将border-radius 应用于已经具有左上/右上边框半径的模态的所有侧面,并假设按钮位于该元素的底角,如果您还添加overflow: hidden 到带有border-radius 的模态框,它将剪切按钮的角。

    body {
      background: #aaa;
      text-align: center;
    }
    div {
      background: #fff;
      border-radius: 1em;
      padding: 1em;
      display: inline-block;
      width: 200px;
      height: 100px;
      position: relative;
      overflow: hidden;
    }
    button {
      position: absolute;
      bottom: 0;
      padding: 0;
      margin: 0;
      width: 50%;
      left: 0;
      padding: .5em 0;
      background: #09c;
      color: white;
      border: 0;
    }
    button:last-child {
      left: auto;
      right: 0;
      border-left: 1px solid white;
    }
    <div>
      <button>button</button>
      <button>button</button>
    </div>

    【讨论】:

    • 我认为模态的边界半径是所有引导模态的默认值。我在页脚处遇到了问题,因为我将 .btn 的边框半径设置为 0px。现在我正在寻找可以让我设置按钮特定角的边框半径的东西,这样我就不必删除边框半径:0px
    • 知道了,其他人已经回答了如何将边框应用到特定角落,所以我只是提供一个替代方案。这个解决方案应该只是添加.modal-footer { overflow: hidden; }
    • 最后,border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; .modal-footer 起初不起作用,但如果我们将overflow: hidden; 添加到它,问题就解决了。谢谢
    • @JkAlombro 甜蜜!
    【解决方案3】:

    在紫色按钮的左下角放置一个边框半径可以在CSS下面使用

    .btn-purple {
    color: #f0f0f0!important;
    background-color: #9c82cd!important;
    font-size: 14px!important;
    border: none!important;
    border-radius: 0 0 0 20px; /*20px is example you can use how much radius you want*/
    }
    

    在灰色按钮的右下角放置一个边框半径。你可以使用下面的CSS

    .btn-gray {
    color: #797979!important;
    background: #e0e0e0!important;
    font-size: 14px!important;
    border: none!important;
    border-radius: 0 0 20px 0;
    }
    

    【讨论】:

    • 我会认为这是不同的方法,因为我已经找到了更好的方法来解决它。稍后会投票:)
    • 当然,就我而言,我在.modal-footer 添加了border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; overflow: hidden;。我更喜欢这个,因为我的一些模态只有一个按钮,所以将特定的边框半径放在按钮本身是不平衡的:)
    【解决方案4】:

    将以下 CSS 添加到您的按钮并相应地进行调整

    -moz-border-radius-topleft: 0px;
    -moz-border-radius-topright:0px;
    -moz-border-radius-bottomleft:5px;
    -moz-border-radius-bottomright:5px;
    -webkit-border-top-left-radius:0px;
    -webkit-border-top-right-radius:0px;
    -webkit-border-bottom-left-radius:5px;
    -webkit-border-bottom-right-radius:5px;
    border-top-left-radius:0px;
    border-top-right-radius:0px;
    border-bottom-left-radius:5px;
    border-bottom-right-radius:5px; 
    

    【讨论】:

      【解决方案5】:

      问题只是一个词序问题:)

      您要查找的属性不是border-radius-bottom-leftborder-radius-bottom-right,而是border-bottom-left-radiusborder-bottom-right-radius

      .modal-footer {
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
      }
      

      希望这会有所帮助! :)

      【讨论】:

      • 我的错,我输入问题时顺序错误。已经编辑过了,谢谢指出。虽然仍然不适合我
      【解决方案6】:

      如前所述,您在 css 中将边框半径设置为零很重要

      #notifier-modal .btn,
      {
      border: none!important;
      border-radius: 0px!important;
      font-family: 'AvenirMedium';
      height: 50px!important;
      }
      

      尝试将其注释掉,然后添加到底部。

      网上有很多资源,但我找到的最好的是

      Border radius

      它可以让您单独或一次性设置边框半径。它还为您提供了要使用的 CSS。

      干杯

      【讨论】:

      • 不知道它将如何帮助我解决我的问题。
      • 您可以在 while 正方形周围的框中添加所需的边框半径,即 0。假设你想要 10px 的半径,你放入 10 并删除你不需要的。
      • 哦,我现在明白了,谢谢。只是它最后仍然以border-bottom-right-radius/left-radius结束。之前已经尝试将其应用到我的代码中,但没有成功
      • #notifier-modal .btn, 的代码中重要的边框半径为 0。尝试删除它,然后将其添加进去。
      • 好的,保持边界为零,然后在底部两个角添加重要标签。看看这是否有效。
      猜你喜欢
      • 1970-01-01
      • 2018-09-22
      • 2021-10-01
      • 1970-01-01
      • 2020-03-14
      • 1970-01-01
      • 1970-01-01
      • 2011-10-27
      • 1970-01-01
      相关资源
      最近更新 更多