【问题标题】:Bootstrap 4 - customized button with text and image on right, flexed for bootstrapBootstrap 4 - 右侧带有文本和图像的自定义按钮,为引导而弯曲
【发布时间】:2018-08-11 20:39:00
【问题描述】:

我想创建一个作为按钮的 div,它包含一张国旗图片和一个国家/地区的 abv,我已经将一些代码放入我想要的内容中,但它不是引导程序的方式,我我很难理解它以及如何使用引导程序来做到这一点。

    <div class="countrylink">
<div class="abvcountry">
    AFG
</div>

<div class="countryflag">
<img src="../../Downloads/afghanistan_texture.gif">
</div>

这是样式。

        .countrylink {
    position:relative;
    width: 260px;
    height: 60px;
    background:olivedrab;
    margin-left: 55px;
    margin-top: 20px;
    float:left;
} 

.abvcountry {
    position:absolute;
    display: inline;
    background-color:#FFBF55;
    width: 60px;
    background:tomato;
    height:60px;
    left:0px;
}

.countryflag {
        position: absolute;
        display: inline;
        background-color: #0FF;
        width: 200px;
        background: blue;
        left: 60px;
        height: 60px;
}

.countryflag img {
width: 100%;
height: 100%;
}

我只是觉得通过 Bootstrap 显示在手机或平板电脑上会更好看

【问题讨论】:

    标签: html twitter-bootstrap button bootstrap-4


    【解决方案1】:

    感谢 WebDevBooster 的帮助!

    我想出了一个我一直在寻找的完美按钮:

    .flg-btn {
      width: 180px;
      !important;
      max-width: 180px;
      margin-bottom: 20px;
      margin-right: 20px;
      padding-left: 0px !important;
      padding-right: 6px !important;
      padding-top: 6px !important;
      padding-bottom: 6px !important;
    }
    
    .flg-list {
      margin: 0;
      max-width: 180px;
      !important;
    }
    
    .flgpic {
      width: 100px;
      max-width: 100px;
      !important;
    }
    
    .abv-txt {
      margin-left: 8px;
      margin-right: 2px !important;
      width: 55px;
      max-width: 55px;
      !important;
    }
    <!doctype html>
    <html lang="en">
    
    <head>
      <!-- Required meta tags -->
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    
      <!-- Bootstrap CSS -->
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
      <script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script>
      <link rel="stylesheet" href="css/stylesheet.css">
    
      <title>title</title>
    </head>
    
    <body>
    
    
      <a class="btn btn-lg px-3 btn-outline-dark align-middle flg-btn" href="#" role="button">
        <!-- ##### AFGHANISTAN ##### -->
        <ul class="list-inline flg-list">
          <li class="list-inline-item abv-txt">
            <h5>AFG</h5>
            <!-- -------------------------------------------------- #### !! ISO Alpha-3 CODES HERE !! #### -->
          </li>
    
          <li class="list-inline-item">
            <img src="img/flags/af.svg" class="rounded flgpic" height="60" width="120" alt="USA flag">
          </li>
        </ul>
      </a>
    
    </body>

    【讨论】:

      【解决方案2】:

      只需使用btn btn-lg 类作为a 标记的基础。

      如果需要,您可以使用px-* 类之一进行水平填充控制:

      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
      
      <p class="mb-0">px-3:</p>
      <a class="btn btn-lg px-3 btn-primary" href="#" role="button">USA <img src="https://lipis.github.io/flag-icon-css/flags/4x3/us.svg" height="30" alt="USA flag"></a>
      <p class="mb-0">px-4:</p>
      <a class="btn btn-lg px-4 btn-primary" href="#" role="button">USA <img src="https://lipis.github.io/flag-icon-css/flags/4x3/us.svg" height="30" alt="USA flag"></a>
      <p class="mb-0">px-5:</p>
      <a class="btn btn-lg px-5 btn-primary" href="#" role="button">USA <img src="https://lipis.github.io/flag-icon-css/flags/4x3/us.svg" height="30" alt="USA flag"></a>

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-04-30
        • 2013-01-07
        • 1970-01-01
        • 2020-02-29
        • 2010-12-21
        • 2018-04-14
        • 1970-01-01
        相关资源
        最近更新 更多