Jump to content
  • 0

Почему background-color красит не только эл-т которому назначен, но и эл-ты поверх него?


Atljh0987
 Share

Question

.down со свойством background-color красит надвинутый на него элемент .up__foot с картинкой, почему так происходит? вот код:

HTML

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/style.css" media="all" />
</head>
<body>
    <div class="up">
        <div class="wrap">
            <div class="up__head"></div>
            <div class="up__foot"></div>
        </div>
    </div>
    <div class="down">
        <div class="wrap">
            <div class="footer"></div>
        </div>
    </div>
</body>
</html>

 

CSS

html, body{
    width:100%;
    height:100%;
    padding:0; margin:0;
}
 
.wrap{
    min-width:500px;
    max-width:70%;
    height:100%;
    margin:0 auto;
}
 
 
.up{
    min-width:592px;
    max-width:70%;
    background:gray;
    height:50%;
    margin:0 auto;
}
 
.head{
    width:500px;
    height:50%;
}
 
.up__head{
    width:100%;
    height:100px;
    background-color:#616262;
    margin-bottom:200px;
}
 
.up__foot{
    background-image:url(../img/lead.jpg);
    background-repeat:no-repeat;
    background-size:cover;
    height:325px;
    width:100%; 
}
 
.down{
    min-width:592px;
    max-width:70%;
    height:50%;
    margin:0 auto;
    background-color:blue;
}

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

ну так в потоке HTML-файла выше отображается тот слой, который ниже по документу. решается z-index-сами. при том, z-index нужно выставлять div.up или отрицательный div.down. Потому что div.up__foot и div.down находятся в разных потоках.

http://htmlbook.ru/samlayout/blochnaya-verstka/nalozhenie-i-poryadok-sloev

Рабочий пример:

https://jsfiddle.net/obma4tem/

Edited by Rumpelstistskin
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy