简体   繁体   English

Bootstrap封面图片不会在移动设备上调整大小

[英]Bootstrap cover image doesn't resize on mobile

I have the following cover image which looks great on desktop. 我有以下封面图片,在桌面上看起来很棒。 The headshot is on the right so when I view the page on mobile the headshot is cutoff. 头像在右侧,因此当我在移动设备上查看页面时,头像被截断了。

How do I make it so the image is resized when going to mobile? 如何制作以便在移动时调整图像大小?

Here's my bootply: http://www.bootply.com/KVei4t3ABg 这是我的bootply: http : //www.bootply.com/KVei4t3ABg

Here's my html: 这是我的html:

<div class="intro-header">
    <div class="container">

        <div class="row">
            <div class="col-lg-7">
                <div class="intro-message">
                    <h1>Title</h1><br>
                    <p class="subtitle">Search the most comprehensive online library </p>
                    <p class="intro-divider"></p>
                     <a href="https://www.apple.com" class="btn btn-primary btn-lg">
                       Register for a Free Account
                     </a>
                </div>
            </div>
        </div>

    </div>
    <!-- /.container -->
</div>

Here's my css: 这是我的CSS:

.intro-header {
    padding-top: 50px; /* If you're making other pages, make sure there is 50px of padding to make sure the navbar doesn't overlap content! */
    padding-bottom: 50px;
    text-align: left;
    color: #f8f8f8;
    background: url(http://www.onvia.com/exchange/img/background_test.jpg) no-repeat center center;
    background-size: cover;
}

Your background image is very wide, but the relevant portion is narrow. 您的背景图片很宽,但相关部分很窄。 I'd consider stripping the gray background, replacing it with CSS color, and setting your portrait to the right edge at all times. 我会考虑剥离灰色背景,将其替换为CSS颜色,并始终将您的肖像设置为右边缘。 Considering the sliced-off shoulder, this is probably a good idea anyway. 考虑到割下的肩膀,无论如何这可能是一个好主意。

.intro-header {
    padding-top: 50px;
    padding-bottom: 50px;
    text-align: left;
    color: #f8f8f8;
    background: url( ... ) no-repeat right center;
    background-size: contain;
    background-color: #ddd;
}

Demo 演示版

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM