簡體   English   中英

鏈接(所有div上方的href)

[英]link ( a href above all divs)

嗨,這是我在網站右側有一個滑動菜單且位置固定的情況。 並且有一個鏈接“”,我想在其上方浮動絕對位置或相對位置,例如z,但我添加z-index10000。絕對位置或固定位置不顯示。 在滑塊div之外。

請檢查圖像。 檢查綠色圓圈

注意: 打開菜單后,會提示#menu關閉

的CSS和HTML說實話我有一個困難時期,謝謝

<a href="#menu" class="close" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></a>



#menu .close {
            background-image: url("images/close.svg");
            background-position: 4.85em 1em;
            background-repeat: no-repeat;
            border: 0;
            cursor: pointer;
            display: block;
            height: 3em;
            position: fixed;
            right: 541px;
            top: 0;
            z-index: 50000;
            display: block;
            vertical-align: middle;
            width: 7em;
        }

HTML

  <div id="header" class="alt">
                <nav id="nav">
                    <ul>
                        <li class="special">


                            <a href="#menu" class="menuToggle"><span> menu</span></a>

                            <div id="menu">
                              <div class="logo_menu">
                                <img src="<?php bloginfo('stylesheet_directory'); ?>/img/logo.png">
                             </div> 
                                    <ul>
                                    <li><a href="<?php bloginfo('url'); ?>">Home</a></li>
                                    <li><a href="<?php bloginfo('url'); ?>/company-values">Company Values</a></li>
                                    <li><a href="<?php bloginfo('url'); ?>/our-services">Our services</a></li>
                                    <li><a href="<?php bloginfo('url'); ?>/need-home-health-care-now">Need Home health care now?</a></li>
                                    <li><a href="<?php bloginfo('url'); ?>/meet-the-team">Meet the Team</a></li>
                                </ul>
                            </div>
                        </li>
                    </ul>

                </nav>

            </div>

CSS

        */
    #header {
         -moz-transition: background-color 0.2s ease;
        -webkit-transition: background-color 0.2s ease;
        -ms-transition: background-color 0.2s ease;
        transition: background-color 0.2s ease;
        background: #2e3842;
        height: 3em;
        left: 112px;
        line-height: 3em;
        position: absolute;
        top: -38px;
        width: 100%;
        z-index: 10000;
    }

        #header h1 {
            -moz-transition: opacity 0.2s ease;
            -webkit-transition: opacity 0.2s ease;
            -ms-transition: opacity 0.2s ease;
            transition: opacity 0.2s ease;
            height: inherit;
            left: 1.25em;
            line-height: inherit;
            position: absolute;
            top: 0;
        }

            #header h1 a {
                border: 0;
                display: block;
                height: inherit;
                line-height: inherit;
            }

                @media screen and (max-width: 736px) {

                    #header h1 a {
                        font-size: 0.8em;
                    }

                }

        #header nav {
            height: inherit;
    line-height: inherit;
    position: absolute;
    right: -5px;
    top: 38px;

        }

            #header nav > ul {
                list-style: none;
                margin: 0;
                padding: 0;
                white-space: nowrap;
            }

                #header nav > ul > li {
                    display: inline-block;
                    padding: 0;
                }

                    #header nav > ul > li > a {
                        border: 0;
                        color: #000;
                        display: block;
                        font-size: 0.8em;
                        padding: 0 1.5em;
                        text-transform: uppercase;
                            padding-left: 0px !important;
                    }

                        #header nav > ul > li > a.menuToggle {
                            outline: 0;
                            position: relative;
                        }

                            #header nav > ul > li > a.menuToggle:before {
                                background-image: url("images/bars.svg");
                                background-position: right center;
                                background-repeat: no-repeat;
                                content: '';
                                display: inline-block;
                                height: 3.75em;
                                vertical-align: top;
                                width: 2em;
                            }

                            @media screen and (max-width: 736px) {

                                #header nav > ul > li > a.menuToggle {
                                    padding: 0 1.5em;
                                }

                                    #header nav > ul > li > a.menuToggle span {
                                        display: none;
                                    }

                            }

                        @media screen and (max-width: 736px) {

                            #header nav > ul > li > a {
                                padding: 0 0 0 1.5em;
                            }

                        }

                    #header nav > ul > li:first-child {
                        margin-left: 0;
                    }

        #header.alt {
            background: transparent;
        }

            #header.alt h1 {
                -moz-pointer-events: none;
                -webkit-pointer-events: none;
                -ms-pointer-events: none;
                pointer-events: none;
                opacity: 0;
            }


.logo_menu {
    margin-bottom: 30px;
}

a.menuToggle {
    text-decoration: none;
}

a.menuToggle span {
    padding-left: 4px;
}

任何時候要將元素絕對放在元素之上,都想將父元素設置為position:relative並將子元素放在父元素中。

<div class="parent">
   <a class="child">Child</a>
</div>

.parent {
  position: relative;
  z-index: 1;
}

.child {
  position: absolute;
  z-index: 2;
  top: 0; //style to taste
  left: 0; //style to taste
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM