首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Bootstrap中重塑卡大小

在Bootstrap中重塑卡大小
EN

Stack Overflow用户
提问于 2020-10-01 07:40:43
回答 1查看 32关注 0票数 1

我正在尝试建立我的网络投资组合,我想要一个卡片格式,其中包括一个图像缩略图和下面的文字。我遇到的问题是无法控制初始图像的大小,这会导致卡片不对齐。

我想知道是否有办法修复它,使它可以调整到任何图像大小。这是我的代码

代码语言:javascript
复制
<!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://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
        crossorigin="anonymous">
        <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.14.0/css/all.css">
    <title>Pattern</title>
</head>

<body>

    <nav class="navbar bg-dark navbar-dark">
        <div class="container">
            <a href="" class="navbar-brand"> <i class="fas fa-code"></i> BODY OF WORK</a>
        </div>
    </nav>

    <section id="header" class="jumbotron text-center">
            <h1 class="display-3">FRANK DIN: WEB DEVELOPER</h1>
    </section>

    <section id="gallery">
        <div class="container">
            <div class="row">
                <div class="col-lg 4 mb-3">
                    <div class="card">
                        <a href=""><img class="card-img-top" src="https://github.com/frankdin1/LandingPage/blob/master/Landing%20Page%20thumbnail.PNG?raw=true"></a>
                        <div class="card-body">
                            <h5 class="card-title">Landing Page</h5>
                            <p class="card-text">Landing page for a fictitious dating site built with Bootstrap.</p>
                            <a href="https://github.com/frankdin1/LandingPage" class="btn btn-outline-primary">Github</a>
                            <a href="PurffectMatch.html" class="btn btn-outline-success">Webpage</a>
                        </div>
                    </div>
                </div>

                <div class="col-lg 4 mb-3">
                    <div class="card">
                        <a href=""><img class="card-img-top" src="https://github.com/frankdin1/Bootstrap-Image-Gallery/blob/master/BootstrapPhotoBlog%20thumbnail.PNG?raw=true"></a>
                        <div class="card-body">
                            <h5 class="card-title">Bootstrap Image Gallery</h5>
                            <p class="card-text">Image gallery built using Bootstrap.</p>
                            <a href="https://github.com/frankdin1/LandingPage" class="btn btn-outline-primary">Github</a>
                            <a href="PurffectMatch.html" class="btn btn-outline-success">Webpage</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
        crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
        crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
        crossorigin="anonymous"></script>
</body>

</html>
EN

回答 1

Stack Overflow用户

发布于 2020-10-01 08:35:29

添加此CSS:

代码语言:javascript
复制
.card-img-top {
    height: 20vw; // change this value and/or units to your liking
    width: 100%;
    object-fit: cover;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64147192

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档