CSS和固定的背景不起作用

时间:2017-09-07 08:16:42

标签: html css

我对右边的图片感到满意。

Image 1

我的图片高度为950像素。我希望它与scrooll同时移动。

如果我添加此属性" 后台附件:修复; ",它可以工作,但图片被缩放,我不想要:(

Image 2

你能帮帮我吗? 这是小提琴:



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
}

<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>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:0)

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%;
}
<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>

答案 1 :(得分:0)

您需要更改lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { //get item id TextView itemID = (TextView) parent.findViewById(R.id.txtID); String text = itemID.getText().toString(); Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show(); } }); 并替换为图片background-size的尺寸,例如backgound-size: cover,其中第一个值是第二个高度