简体   繁体   English

如何将底部菜单重叠在图像顶部并将其居中?

[英]How can I overlap the Bottom Menu on top of the image and center it?

I've already set the navbar, the image with the text, and the under part is going to be another menu.我已经设置了导航栏,带有文本的图像,下面的部分将是另一个菜单。 How an I first of all center the bottom menu and overlap it on the image as in the example?我如何首先将底部菜单居中并将其重叠在图像上,如示例中所示? This is How I want it to look这就是我想要的样子

On the other hand, this is How it looks另一方面,这就是它的样子

I've only placed the code of the image and the under part since the code of the nav bar doesn't matter我只放置了图像的代码和下面的部分,因为导航栏的代码无关紧要

HTML HTML

<!DOCTYPE html>
  <html>
    <head>
      <meta charset='UTF-8'/>
      <title>SerFin</title>
      <link href="https://fonts.googleapis.com/css?family=Lato:300,700|Prata" rel="stylesheet">
      <style>
        .HomeTabImage {
          background-image: url('Images/Chairs.jpg');
          width: 100%;
          background-position: center;
          background-repeat: no-repeat;
          background-size: cover;
        }
      </style>
      <script>

      </script>
      <link rel='stylesheet' href='Styles.css'/>
    </head>
    <body>
      <header class="TopMenu">
        <nav class="TopSetup-Container">
          <img src="Images/Logo.png"/ id="Logo">
          <ul class="Menu">
            <li><a href="#">Login</a></li>
            <li><a href="#">Sign Up</a></li>
            <li><a href="#">Contact Us</a></li>
          </ul>
          <ul class="Menu">
            <li><a href="#">Support</a></li>
            <li><a href="#">About Us</a></li>
            <li><a href="#">Submission</a></li>
            <li><a href="#">Tutorial</a></li>
          </ul>
        </nav>
      </header>
      <article class="HomeTabImage">
        <h1> Service Finder </h1>
        <p> Let the opportunities begin </p>
        <p> Everything we do is driven by opportunities </p>
        <p> Search and provide services </p>
      </article>
      <article class="Services">
          <h3 id="HomeTabServicesTitle"> Here are the services provided by the community </h3>
          <div class="ServicesContainer">
          <ul class="Options">
            <li><a href="#">Univeristies<br>🎓</br></a></li>
            <li><a href="#">Internships<br>📊</br></a></li>
            <li><a href="#">Courses<br>💻</br></a></li>
            <li><a href="#">Jobs<br>💼</br></a></li>
            <li><a href="#">Services<br>🌐</br></a></li>
          </ul>
        </div>
      </article>
    </body>
  </html>

CSS CSS

.HomeTabImage  {
  height: 340px;
  width: 100%;
  text-align: center;
  line-height: normal;
}

.HomeTabImage h1 {
  font-size: 70px;
  color: black;
}

.HomeTabImage p {
  font-size: 50px;
  color: black;
}

/*Home Tab Info part*/
.Services {
  text-align: center;
  width: 80%;
}

.Services p {
  width: 640px;
}

.ServicesContainer {

}

#HomeTabServicesTitle {
  color: #828282;
  border-bottom: 2px solid #8B8C8C;
  padding-top: 20px;
  padding-bottom: 10px;
}

.Options {
  display: flex;
  justify-content: space-around;
  width: 100%;
  padding-top: 20px;
}

.Options li {
  list-style: none;
}

.Options a {
  font-size: 25px;
}

To center it, use margin-left: 10%;要使其居中,请使用margin-left: 10%; . .

For overlapping try using z-index: 2;对于重叠尝试使用z-index: 2; . .

如何重叠顶部<div>和一个底部<div>进入图像而不产生丑陋/凌乱的空白?</div><div id="text_translate"><p> 我的 html 中有一个顶部 div、一个图像和一个底部 div,我想将 2 个 div 重叠到我的图像中,第一个 div 应该覆盖图像顶部的一些区域,底部 div 应该覆盖一些图像底部的区域,div 应该是覆盖图像的那个(在显示器的前面)。 我将如何以一种干净的方式(不留空白)并使其对视图或父 div 的宽度做出响应?</p><p> <strong>这是我的 html</strong> </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-css lang-css prettyprint-override"> * { padding: 0px; margin: 0px; } #image { max-width: 100%; }.rects { height: 100px; } #rect-top { background-image: linear-gradient(45deg, rgba(0, 194, 228, 0.75), rgba(214, 0, 203, 0.479)); } #rect-bottom { background-image: linear-gradient(45deg, rgba(214, 0, 203, 0.479), rgba(0, 194, 228, 0.75)); }</pre><pre class="snippet-code-html lang-html prettyprint-override"> &lt;h1&gt;Start&lt;/h1&gt; &lt;div id="rect-top" class="rects"&gt;&lt;/div&gt; &lt;img id="image" src="image-with-gradient.jpg"&gt; &lt;div id="rect-bottom" class="rects"&gt;&lt;/div&gt; &lt;h1&gt;End&lt;/h1&gt;</pre></div></div><p></p><p> <strong>这就是我想要实现的目标:</strong></p><p> <a href="https://i.stack.imgur.com/y9g7M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y9g7M.png" alt="在此处输入图像描述"></a></p><p> 如您所见,在<strong>h1</strong>标签之前和之后没有空格</p></div></div> - how to overlap a top <div> and a bottom <div> into an image without generating ugly/messy white spaces?

暂无
暂无

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

相关问题 如何在div的顶部和底部之间居中显示文本? - How can I center text between the top and bottom of a div? 如何平均缩小顶部和底部页边距,但保持中心菜单一致? - How to shrink top and bottom margins equally but keep center menu consistent? 如何将图像放在英雄部分的顶部? - How can I center an image on top of a hero section? 如何使图像栏保持在手机菜单的最上方? - How can I make an image bar to stay on top with the menu on mobile? 我可以将徽标移动到顶部菜单的中心吗? - Can I move my logo to center of top menu? 如何重叠顶部<div>和一个底部<div>进入图像而不产生丑陋/凌乱的空白?</div><div id="text_translate"><p> 我的 html 中有一个顶部 div、一个图像和一个底部 div,我想将 2 个 div 重叠到我的图像中,第一个 div 应该覆盖图像顶部的一些区域,底部 div 应该覆盖一些图像底部的区域,div 应该是覆盖图像的那个(在显示器的前面)。 我将如何以一种干净的方式(不留空白)并使其对视图或父 div 的宽度做出响应?</p><p> <strong>这是我的 html</strong> </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-css lang-css prettyprint-override"> * { padding: 0px; margin: 0px; } #image { max-width: 100%; }.rects { height: 100px; } #rect-top { background-image: linear-gradient(45deg, rgba(0, 194, 228, 0.75), rgba(214, 0, 203, 0.479)); } #rect-bottom { background-image: linear-gradient(45deg, rgba(214, 0, 203, 0.479), rgba(0, 194, 228, 0.75)); }</pre><pre class="snippet-code-html lang-html prettyprint-override"> &lt;h1&gt;Start&lt;/h1&gt; &lt;div id="rect-top" class="rects"&gt;&lt;/div&gt; &lt;img id="image" src="image-with-gradient.jpg"&gt; &lt;div id="rect-bottom" class="rects"&gt;&lt;/div&gt; &lt;h1&gt;End&lt;/h1&gt;</pre></div></div><p></p><p> <strong>这就是我想要实现的目标:</strong></p><p> <a href="https://i.stack.imgur.com/y9g7M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y9g7M.png" alt="在此处输入图像描述"></a></p><p> 如您所见,在<strong>h1</strong>标签之前和之后没有空格</p></div></div> - how to overlap a top <div> and a bottom <div> into an image without generating ugly/messy white spaces? 如何在同一页面上通过侧边栏和顶部菜单响应地居中我的 div 内容? - How can I center my div content responsively with sidebar and top menu on the same page? 如何使此文本和图像不重叠 - How can I make this text and image not overlap 如何在离子中将 img 重叠在另一个 img 之上 - How can I overlap an img on top of another one in ionic 如何将表格置于本网站顶部的中心? - How can I center the form at the top of this website?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM