首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS和固定背景不工作

CSS和固定背景不工作
EN

Stack Overflow用户
提问于 2017-09-07 08:16:41
回答 2查看 50关注 0票数 0

我对右边的图片很满意。

我的照片有950像素的高度。我希望它能和卷轴同时移动。

如果我添加了这个属性“背景-附件:固定的; ",它可以工作,但是图像被放大,我不想:

你能帮我吗?,我是

代码语言:javascript
复制
body {
    background: #f2f2f2;
    font-family: Open Sans, Helvetica, Arial, Tahoma, Sans-Serif
}

/*  --------------------------------------------------
/*  Text-transform
/*  --------------------------------------------------
*/
.content-image-left-right {
    background-color: #fff
}

.content-image-left-right h2 {
    margin-top: 3rem;
    margin-bottom: 3rem;
    font-weight: bold;
    letter-spacing: .4rem;
    text-align: center;
    text-transform: uppercase
}

.content-image-left-right p {
    max-width: 450px;
    color: #605e5e;
    margin-right: auto;
    margin-left: auto;
    text-align: justify
}

.content-image-left-right .cover {
    height: 550px;
    background-image: url(https://img11.hostingpics.net/pics/422842background3.png);
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover
}
代码语言:javascript
复制
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>

        <div class='content-image-left-right'>
            <div class="row">
                <div class="col">
                    <h2>
                        Gérer
                    </h2>
                    <p>
                        Grâce à notre solution <strong>complète et assistée</strong>, Dometech vous permet <strong>une gestion simple et centralisée de tous vos biens</strong>.
                    </p>
                </div>
                <div class="col cover background-3">

                </div>
            </div>
        </div>

EN

回答 2

Stack Overflow用户

发布于 2017-09-07 08:27:12

代码语言:javascript
复制
body {
    background: #f2f2f2;
    font-family: Open Sans, Helvetica, Arial, Tahoma, Sans-Serif
}

/*  --------------------------------------------------
/*  Text-transform
/*  --------------------------------------------------
*/
.content-image-left-right {
    background-color: #fff
}

.content-image-left-right h2 {
    margin-top: 3rem;
    margin-bottom: 3rem;
    font-weight: bold;
    letter-spacing: .4rem;
    text-align: center;
    text-transform: uppercase
}

.content-image-left-right p {
    max-width: 450px;
    color: #605e5e;
    margin-right: auto;
    margin-left: auto;
    text-align: justify
}

.content-image-left-right .cover {
    height: 550px;
    background-image: url(https://img11.hostingpics.net/pics/422842background3.png);
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 550px 100%;
}
代码语言:javascript
复制
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>

        <div class='content-image-left-right'>
            <div class="row">
                <div class="col">
                    <h2>
                        Gérer
                    </h2>
                    <p>
                        Grâce à notre solution <strong>complète et assistée</strong>, Dometech vous permet <strong>une gestion simple et centralisée de tous vos biens</strong>.
                    </p>
                </div>
                <div class="col cover background-3">

                </div>
            </div>
        </div>

票数 0
EN

Stack Overflow用户

发布于 2017-09-07 10:34:06

您需要更改backgound-size: cover,并将其替换为图像背景尺寸的大小,例如,第一个值为宽度、第二个高度的background-size: 550px 300px

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46091324

复制
相关文章

相似问题

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