将<div>放在绝对<div>

时间:2019-10-09 16:08:54

标签: html css

我正在为我的业务设计一个网站。我在标题部分中有一个<img>,类为“ nav”。 它的位置是绝对位置,z-index -3放置在菜单部分下方。 我在父类<div>中还有其他三个<div>标签,其类别为:标头部分之后的内容。但内容div将放置在上一个div的图像上。我希望将其放在上一个div之后。

        * {
            margin: 0;
            padding: 0;
        }

        img {
            z-index: -3;
            position: absolute;
            width: 100%;
            background-repeat: no-repeat;

        }

        .container {
            width: 100%;
            margin: 0 auto;
            font-family: 'morteza';

        }


        .xHead {
            width: 100%;
            height: 160px;
            background-color: rgba(0, 0, 0, 0.6);
            padding-top: 5px;
            position: relative;


        }

        div.xSlider {
            width: 100%;
            line-height: 10px;
            background-color: #c8fcb6;
        }

        .xTopBanner {
            width: 100%;
            height: 50px;
            display: block;
            margin: 0 auto;
            background-color: #100e17;
            color: #c8fff7;
            direction: rtl;
            text-align: center;


        }

        div p {
            padding-top: 10px;
        }

        div.xSidebar {
            background-color: #ffc0ae;
            width: 25%;
            height: 150px;
            float: left;


        }

        div.xBody {
            background-color: #9db7ff;
            width: 75%;
            height: 150px;
            float: left;
            display: flex;
            justify-content: center; /* center horizontally */
            align-items: center; /* center vertically */


        }

        div.xFooter {
            width: 100%;
            height: 50px;
            background-color: #c8fff7;
            clear: both;
        }

        div.xCopyright {
            width: 100%;
            height: 20px;
            background-color: #fff359;
        }


        .logo {
            width: 110px;
            padding-top: 25px;

            vertical-align: middle;
            position: absolute;
            left: 20%;
            bottom: 45px;
            z-index: 5;

        }

        ul {
            list-style-type: none;
            direction: rtl;
            margin-right: 100px;

        }

        li {
            display: inline-block;

            padding: 5px 5px 1px 5px;
            margin-left: 10px;
            margin-top: 60px;
            border-radius: 5px 5px 0px 0px;
            font-size: 20px;
        }

        .nav {
            color: white;

        }

        li::before {
            height: 55%;
            position: absolute;
            width: 25px;
            content: '';
            right: 50;
            border-right: 1px dashed rgba(255, 255, 255, 0.2);
            top: 55px;
        }
<body>
<div class="container">

    <header class="xHead"> <!-- div xHead -->
        <div class="xTopBanner"><p>My business</p></div>

        <a href="www.google.com"><img src="https://images.freeimages.com/images/large-previews/1d9/warning-icons-variations-set-1164186.jpg" alt="" class="logo"></a>

        <div class="nav">
            <img src="https://images.freeimages.com/images/large-previews/d84/colorful-1186913.jpg" alt="">

            <ul>

                <li>main</li>
                <li>contacts</li>
                <li>shop</li>
                <li>regulations</li>
                </li>


            </ul>
        </div>
    </header>  <!-- div xHead -->
    <div class="content">
        <div class="xSidebar"> sidebar</div>
        <div class="xBody">site content</div>
        <div class="xFooter">footer</div>
        <div class="xCopyright">copyright</div>
    </div>
</div>
</body>

0 个答案:

没有答案