0

我的网页上有以下代码:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  

    <asp:PlaceHolder runat="server">
        <%: Scripts.Render("~/bundles/modernizr") %>
    </asp:PlaceHolder>

    <webopt:bundlereference runat="server" path="~/Content/css" />
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
 <link rel="stylesheet" href="Styles/new.css" />
    <style>
            .navbar-brand {    
    display: flex;
    white-space: normal;
    }
    </style>

</head>
<body style="background-color:cadetblue">
    <form id="form1" runat="server">
        <asp:ScriptManager ID="s" runat="server"></asp:ScriptManager>
   <nav class="navbar" style="background-color: #264653; margin:0px auto; max-width:900px; ">
      <div class="container-fluid">
        <span class="navbar-brand" style="display:flex; white-space: normal;">
      <img src="~/Images/Logo_Circle.png" alt="RCA" width="80" height="80" class="d-inline-block align-middle mr-2" runat="server" />
       <span style="font-size:25px;color:white;"><span style="color:#e4b16d">City  of Testing</span><br />This is the company name</span>
        </span>
      </div>
    </nav>

   <div style="background-color:white;border-radius:10px;align-content:center;align-self:center;vertical-align:middle;width:100%" class="container max-width-940 body-content">
      <div style="margin-top: 0px">

        <asp:UpdatePanel ID="updatePanel2" runat="server">
          <ContentTemplate>
            <div style="align-items:center; justify-content:left;display:flex;font-size:24px"><b>Recording test testing</b></div>
            <div>&nbsp;</div>
            <div>
              <span style="font-size:18px"> This is a test1. This is a test2.This is a test3.This is a test4.This is a test5.This is a test6.This is a test7.This is a test8.This is a test9.This is a test10.This is a test11This is a test12This is a test13This is a test14This is a test15This is a test16This is a test17This is a test18This is a test19This is a test20This is a test21This is a test22This is a test23This is a test24.</span>
            </div>
            <div>&nbsp;</div>

          </ContentTemplate>
        </asp:UpdatePanel>
      </div>
    </div>
     
 

我希望导航栏完全刷新到浏览器窗口的顶部。我看到浏览器窗口和导航栏之间有一个空格。下面是截图。我想摆脱红色箭头所在的空间。在尝试刷新顶部的导航栏时,我希望页面也能响应。

在此处输入图像描述

我想要这样的东西:

在此处输入图像描述

@media (min-width: 992px) {
    .container.max-width-940 {
        max-width: 1390px !important;
    }
}

@media (min-width: 1200px) {
    .container.max-width-940 {
        max-width: 1390px !important;
    }
}

.container.max-width-940 {
    min-width: 1390px !important;
}
4

3 回答 3

1

您的navbar-brand类将white-space属性设置为nowrap,如果容器变得比其中的文本小,它会阻止文本换行。

如果将其更改为normal文本将中断,并允许容器变小。

此外,您navbar是绝对定位的,这将其从文档流中取出。如果您将其居中margin:0px auto并删除绝对定位,则如果其高度发生变化,您下方的内容将自动下推。

.navbar-brand {    
    display: flex;
    white-space: normal;
    }
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
  <title></title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />

  <!--
  <asp:PlaceHolder runat="server">
    <%: Scripts.Render("~/bundles/modernizr") %>
  </asp:PlaceHolder>
 
  <webopt:bundlereference runat="server" path="~/Content/css" />
  -->
  <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />

  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous" />

  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  <!--
  <link rel="stylesheet" href="Styles/new.css" />
  -->
</head>

<body style="background-color:cadetblue">
  <form id="form1" runat="server">
    <asp:ScriptManager ID="s" runat="server"></asp:ScriptManager>
    <nav class="navbar" style="background-color: #264653; margin:0px auto; max-width:900px; ">
      <div class="container-fluid">
        <span class="navbar-brand" style="display:flex; white-space: normal;">
      <img src="~/Images/Logo_Circle.png" alt="RCA" width="80" height="80" class="d-inline-block align-middle mr-2" runat="server" />
       <span style="font-size:25px;color:white;"><span style="color:#e4b16d">City  of Testing</span><br />This is the company name</span>
        </span>
      </div>
    </nav>



    <div style="background-color:white;border-radius:10px;align-content:center;align-self:center;vertical-align:middle;width:100%" class="container max-width-940 body-content">
      <div style="margin-top: 0px">

        <asp:UpdatePanel ID="updatePanel2" runat="server">
          <ContentTemplate>
            <div style="align-items:center; justify-content:left;display:flex;font-size:24px"><b>Recording test testing</b></div>
            <div>&nbsp;</div>
            <div>
              <span style="font-size:18px"> This is a test1. This is a test2.This is a test3.This is a test4.This is a test5.This is a test6.This is a test7.This is a test8.This is a test9.This is a test10.This is a test11This is a test12This is a test13This is a test14This is a test15This is a test16This is a test17This is a test18This is a test19This is a test20This is a test21This is a test22This is a test23This is a test24.</span>
            </div>
            <div>&nbsp;</div>

          </ContentTemplate>
        </asp:UpdatePanel>
      </div>
    </div>






  </form>
</body>

</html>

于 2021-09-15T09:58:49.247 回答
0

尝试执行一些“@media”规则,其中如果页面达到一定大小,它将根据您在类或 id 中设置的条件进行重组。检查此链接。

https://www.w3schools.com/cssref/css3_pr_mediaquery.asp

于 2021-09-15T09:38:38.817 回答
-1

overflow-wrap: break-word;在容器上使用css 属性

于 2021-09-15T09:40:08.290 回答