Iframe z-index for Drop down menu

耗尽温柔 提交于 2019-12-13 12:21:58

问题


I've got code for a drop down menu and my goal is to load that code via an iFrame. Unfortunately I could not figure out how to load the view elements outside of the iFrame using the Z-index. The code is as follows:

 <style type="text/css">

     /*Initialize*/
      ul#menu, ul#menu ul.sub-menu 
      {
          padding:0;
          margin: 0;
      }


      ul#menu li, ul#menu ul.sub-menu li 
      {

          list-style-type: none;
          display: inline-block;
      }


      /*Link Appearance*/
      ul#menu li a, ul#menu li ul.sub-menu li a 
      {
           text-decoration: none;
           color: #fff;
           background: #666;
           padding: 5px;
           display:inline-block;
      }



    /*Make the parent of sub-menu relative*/

          ul#menu li 
          {
              position: relative;
          }

           /*sub menu*/
          ul#menu li ul.sub-menu 
          {

            display:none;
            position: absolute;
            top: 30px;
            left: 0;
            width: 100px;
         }

          ul#menu li:hover ul.sub-menu
          {

               display:block;

          }

         </style>


 <ul id="menu">

<li>
    <a href="#">Menu 1</a>
</li>

<li>

   <a href="#">Menu 2</a>

    <ul class="sub-menu">
        <li>
            <a href="#">Sub Menu 1</a>
        </li>
        <li>
            <a href="#">Sub Menu 2</a>
        </li>
        <li>
            <a href="#">Sub Menu 3</a>
        </li>
        <li>
            <a href="#">Sub Menu 4</a>
        </li>
    </ul>
</li>
<li><a href="#">Menu 3</a>

</li>
<li><a href="#">Menu 4</a>

    <ul class="sub-menu">
        <li>
            <a href="#">Sub Menu 1</a>
        </li>
        <li>
            <a href="#">Sub Menu 2</a>
        </li>
        <li>
            <a href="#">Sub Menu 3</a>
        </li>
        <li>
            <a href="#">Sub Menu 4</a>
        </li>
    </ul>
</li>
<li>
    <a href="#">Menu 5</a>
</li>
 </ul>


   I have written the code for i frame. The drop down menu is in "test.html"

   <iframe src="test.html" width="500" height="30"></iframe>



  so i want load this  css drop down menu in a iframe but the list view should come out of the iframe so how to do it , Please help me .

回答1:


Your static pages must be written with the following code:

<iframe src="test.html" style="position: absolute; width: 500px; height: 100%; top: 0; bottom: 0; z-index: 1000; border: 0;"></iframe>

<div style="margin-top: 60px;">
    .... your content here ...  
</div>



回答2:


Iframe's overflow problem

You can't have visible overflow from an iframe. Also, iframes are bad practice in general!

There are better alternatives to iframes if you're wanting to include a file's code so as not to have it written in every HTML file for your website. Look into server-side includes. However, you WILL need some kind of server to process such requests.

If you're wanting to stick with pure front-end stuff, try using JavaScript to switch content around or AJAX Requests to load new content when you click on the navigation buttons.




回答3:


try:

<iframe seamless src="test.html"></iframe>


来源:https://stackoverflow.com/questions/18213299/iframe-z-index-for-drop-down-menu

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!