html - Bootstrap 4 - 右侧带有文本和图像的自定义按钮,为 Bootstrap 弯曲

标签 html twitter-bootstrap button bootstrap-4

我想创建一个 div,它是一个按钮,它包含一个国旗的图片和一个国家的 abv,我已经将一些代码放入我想要的内容中,但这不是 Bootstrap 的方式,我'我正在努力解决这个问题,以及如何使用 bootstrap 来做到这一点。

    <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 看起来会好很多

最佳答案

只需使用 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>

关于html - Bootstrap 4 - 右侧带有文本和图像的自定义按钮,为 Bootstrap 弯曲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49089320/

相关文章:

javascript - 如何在浏览器中动态更改 JPEG 对比度和缩放级别

css - Bootstrap 多级菜单

javascript - 如何将导航元素的方向从 ltr 更改为 rtl?

swift - 当文本字段中有整数时按钮不启用/禁用

ios - 在 View Controller 之间切换

php - 使用 CSS 将屏幕分成两半

html - JsonML 中如何表示未闭合的标签?

c# - 在 GridView 中启用和禁用按钮

javascript - $(window).width() 没有正确给出视口(viewport)宽度

css - Bootstrap 更改导航文本颜色