【问题标题】:How to remove unwanted gap between <ul> tag and a div如何消除 <ul> 标签和 div 之间不需要的间隙
【发布时间】:2023-04-02 22:47:01
【问题描述】:

我在尝试消除导航栏和应该显示在导航栏下方的 div 之间的间隙时遇到问题。

这是我的代码:

<%-- Nav Bar --%>

    <ul>
        <li> <a class="welcometitle"> Welcome back! <asp:Label ID="lblusuario" runat="server" ForeColor="#99ccff" Font-Bold="true"></asp:Label></a></li>
        <li class="dropdown">
            <div class="dropdown">
                <button onclick="myFunction()" class="dropbtn"> <i class="fa fa-bars"></i> </button>
                <div id="myDropdown" class="dropdown-content">
                      <a href="#home">Home</a>
                      <a href="#about">About</a>
                      <a href="#contact">Contact</a>
                </div>
          </div>
        </li>
    </ul>

<%-- Iframe --%>

<div class="h_iframe">
    <iframe src="inicio.aspx" name="ventana" ></iframe>
</div>

这是我正在使用的 CSS:

body
{
    font: 14px 'Segoe UI', 'Helvetica Neue', 'Droid Sans', Arial, Tahoma, Geneva, Sans-serif;
    overflow-y: hidden;
}

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
}
.h_iframe iframe {
    width: 100%;
    height: 100%;
    margin-top: 0;
}
.h_iframe {
    height: 100%;
    width: 100%;
    margin-top: 0;
    top: 0;
    z-index: -1;
    padding-left: 159px;
    position: fixed absolute
}

.welcometitle {
  float: left;
  display: block;
  color: white;
  text-align: center;
  padding: 1px 16px;
  padding-top: 12px;
  text-decoration: none;
  font-size: 20px;
  font-weight: 500;
}

ul {
  list-style-type: none;
  margin: 0;
  overflow: hidden;
  background-color: #006cb4;
  padding-left: 163px;
}

li {
  float: left;
}

li a {
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

li a:hover:not(.active) {
  color: white;
}

.active {
  background-color: #4CAF50;
}


.li input[type=text] {
  padding: 6px;
  margin-top: 8px;
  font-size: 25px;
  border: none;
}
        img {
          width: 92%;
          padding-left: 8px;
          margin: 0;
          top: 0;
        }

        .dropbtn {
          background-color: #111;
          color: white;
          padding: 16px;
          font-size: 16px;
          border: none;
          cursor: pointer;
        }

        .dropbtn:hover, .dropbtn:focus {
          background-color: #d4d4d4;
          color: #111;
        }

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

        .dropdown-content {
          display: none;
          position: absolute;
          background-color: #f1f1f1;
          min-width: 160px;
          overflow: auto;
          box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
          z-index: 1;
          right: 0;
        }

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

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

        .show {display: block;
               position: fixed;
        }

        .active {
          background-color: #4CAF50;
        }

我尝试了不同的方法,但它似乎不起作用。你能找到我搞砸的地方吗?

【问题讨论】:

  • 请注意,这个position: fixed absolute 不存在。
  • 您的代码不完整。请分享所有相关代码。把它放在一个 sn-p 中,这样我们就可以真正看到问题所在。您的屏幕截图在那里没有多大作用.. ;)
  • 更改您的问题以提供代码 sn-p。

标签: html css asp.net


【解决方案1】:

您可以在 iframe 类中添加一些小 CSS。

代码如下:

.h_iframe {
    margin-top: -20px;
}

【讨论】:

  • 嗯......这完成了这项工作。谢谢你praneeth madush!我仍然不知道为什么 ul 在 div 之前添加了一个额外的空格。无论如何,谢谢!
猜你喜欢
  • 2016-09-28
  • 1970-01-01
  • 2020-10-03
  • 2017-05-26
  • 2018-06-14
  • 2018-11-03
  • 2015-01-21
  • 1970-01-01
  • 2016-04-02
相关资源
最近更新 更多