简体   繁体   English

如何重叠 iframe 标签的内容

[英]how to overlap contents of iframe tag

I have made this search bar... And i want to use this page on many pages using iframe tag.我制作了这个搜索栏……我想在许多使用 iframe 标签的页面上使用这个页面。 But when i use it and when results are shown, it shifts other elements, or a scroll bar is visible ... I want the result to overlaped on the other contents of the site... So that it is visible normally... here is my code---但是当我使用它并显示结果时,它会移动其他元素,或者滚动条可见......我希望结果重叠在网站的其他内容上......以便它正常可见......这是我的代码---

function filterFunction() {
    let isInputAvail = false;
    var input, filter, ul, li, a, i;
    input = document.getElementById("myInput");
    filter = input.value.toLowerCase();
    if (filter.length > 0) {
        document.getElementById("myDropdown").classList.add("show");
    } else {
        document.getElementById("myDropdown").classList.remove("show");
    }
    div = document.getElementById("myDropdown");
    a = div.getElementsByTagName("a");
    for (i = 0; i < a.length; i++) {
        txtValue = a[i].innerText;
        if (txtValue.toLowerCase().indexOf(filter) > -1) {
            isInputAvail = true;
            a[i].style.display = "block";
        } else {
            a[i].style.display = "none";
        }
    }
    if (!isInputAvail) {
        document.getElementById("noMatches").classList.add('show');
    } else {
        document.getElementById("noMatches").classList.remove('show');
    }
}
.div {
    display: none;
}

.dropbtn {
    padding: 16px;
    font-size: 16px;
    border: none;
    cursor: pointer;
    border-radius: 25px;
}

#myInput {
    box-sizing: border-box;
    background-position: 14px 12px;
    background-repeat: no-repeat;
    font-size: 16px;
    padding: 14px 20px 12px 45px;
    border: 5px solid #ddd;
    border-radius: 25px;
}

#myInput:focus {
    outline: 4px solid #f2f2f2;
    border-color: #171313;
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    max-height: 215px;
    display: none;
    position: absolute;
    background-color: #f6f6f6;
    min-width: 230px;
    overflow-y: scroll;
    border: none;
    z-index: 1;
    border-radius: 25px;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
}

.dropdown a:hover {
    background-color: #ddd;
}

.show {
    display: block;
}
<div class="dropdown">
      <input type="text" class="dropbtn"  placeholder="Search Here..." id="myInput" onInput="filterFunction()">
      <div id="myDropdown" class="dropdown-content">
             <a href="#">Result 1</a>
        <a href="#">Result 2</a>
        <a href="#">Result 3</a>
        <a href="#">Result 4</a>
        <a href="#">Result 5</a>
        <a href="#">Result 6</a>
        <a href="#">Result 7</a>
        <a href="#">Result 8</a>
        <a href="#">Result 9</a>
        <a href="#">Result 10</a>
        <a href="#">Result 11</a>
        <a href="#">Result 12</a>
        <a href="#">Result 13</a>
        <a href="#">Result 14</a>
        <a href="#">Result 15</a>
      </div>
      <div id="noMatches" class="dropdown-content">
        <a href="#tools">No Matches</a>
      </div>
    </div>

I still don't get was this what you meant.我仍然不明白这是你的意思。

<style>
.dropbtn{
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
border-radius: 25px;
}

#myInput{
box-sizing: border-box;
background-position: 14px 12px;
background-repeat: no-repeat;
font-size: 16px;
padding: 14px 20px 12px 45px;
border: 5px solid #ddd;
border-radius: 25px;
}

#myInput:focus{
outline: 4px solid #f2f2f2;
border-color: #171313;
}

.dropdown{
position: relative;
display: inline-block;
flex-direction: column;
justify-content: flex-start;
}

.dropdown-content{
max-height: 215px;
display: none;
top: 60px;
left: 0;
position: absolute;
background-color: #f6f6f6;
min-width: 230px;
max-width: 70px;
overflow-y: scroll;
border: none;
z-index: 1;
border-radius: 25px;
}

.dropdown-content a{
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}

.dropdown a:hover{background-color: #ddd;}

.show{display: block;}

body{margin: 0;}
.header{
height: 90px;width: 100vw;
display: flex;position: relative;
align-items: center;
justify-content: space-around;
z-index: 10;
}
.dropdown-content::-webkit-scrollbar{
background: transparent;
width: 0;
display: none;
}

.banner{
background-color: #AAA;color: white;
height: 150px;width: 100vw;
top: 90px;left: 0;
display: block;position: absolute;
z-index: 1;
}
</style>



<div class="header">
<div class="dropdown">
<input type="text" class="dropbtn"placeholder="Search Here..." id="myInput" onInput="filterFunction()"/>
<div id="myDropdown" class="dropdown-content">
<a href="#">Result 1 a very long long line one result</a>
<a href="#">Result 2</a>
<a href="#">Result 3</a>
<a href="#">Result 4</a>
<a href="#">Result 5</a>
<a href="#">Result 6</a>
<a href="#">Result 7</a>
<a href="#">Result 8</a>
<a href="#">Result 9</a>
<a href="#">Result 10</a>
<a href="#">Result 11</a>
<a href="#">Result 12</a>
<a href="#">Result 13</a>
<a href="#">Result 14</a>
<a href="#">Result 15</a>
</div>
<div id="noMatches" class="dropdown-content">
<a href="#tools">No Matches</a>
</div>
</div>
<div>Other</div>
</div>
<div class="banner">Banner Content<div>

Don't get it but is it something like top: 60px;left: 0;不明白,是不是像 top: 60px;left: 0; 这样的东西? in .dropdown-content?在 .dropdown-content 中?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM