【问题标题】:Header not responsive, causing overlap on buttons标题无响应,导致按钮重叠
【发布时间】:2021-10-16 03:11:48
【问题描述】:

我是 Web 开发的新手,我正在尝试找出我在标题方面遇到的问题。我希望我的标题是响应式的,并且不会导致它旁边的按钮元素重叠。

我尝试将positionfloattransform 元素分别单独应用到标题部​​分,但这似乎不能解决问题,或者我只是不知道如何正确使用它们.

下面是我的 html 和 css 的示例。

HTML:

<header>
   <a href="Website.html"><img id="smallLogo" src="/Users/ultimateorganism/Desktop/Brown-Dev-Proj-Vol.1/FuturUImages/smallLogo.png" alt="smallLogo"></a> 
    <h1 class="bizPage">FuturU</h1>
    <div class="homeButtons">
        <a href="Website.html" class="btn btn-outline-light" id="linkHomePage">Home</a>
        <a href="Mindmovies.html" class="btn btn-outline-light" id="linkMindMovies">MindMovies</a>
        <a href="mailto:pbusko5@gmail.com?subject=I am interested in an affirmation/mindmap!" class="btn btn-outline-light" id="linkContact">Contact</a>
        <a href="About.html" class="btn btn-outline-light" id="linkAbout">About</a>
        <a href="Testimonials.html" class="btn btn-outline-light" id="linkTestimonials">Testimonials</a>
        <hr style="background-color: white; height: 3px; opacity: initial;">
    </div>
    <hr style="background-color: white; height: 3px; opacity: initial;">
  </header>

CSS 类:

#smallLogo{
width: 110px;
height: 110px;
float: left;
}

.bizPage{
font-size: 80px;
color: white;
position: relative;
top: 30%;
left: 30%;
}

header{
background-color: black;
font-family: Courier;
justify-content: center;
}

.homeButtons{
position: absolute;
top: 32px;
right: 26px;
font-size: 8px;
}   

.lineHeader, .lineFooter{
   margin-left: auto;
margin-right: auto;
color: white;
height: 3px;
width: auto;
{

对此的任何解决方案将不胜感激。谢谢

【问题讨论】:

    标签: html css header format html-heading


    【解决方案1】:

    基本上,如果您想制作一个完全响应的页面/导航栏,您可能需要使用“汉堡菜单”。看起来你已经使用了 Bootstrap。可以看this link

    不过,我仍在努力提供一个可衡量的解决方案。根据需要检查代码和样式。我只是在 html 部分使用了一个 flex div。

    header{
        width: 100%;
    }
    #smallLogo{
        width: 110px;
        height: 110px;
        /* float: left; */
        }
        
        .bizPage{
        font-size: 80px;
        color: white;
        /* position: relative; */
        top: 30%;
        /* left: 30%; */
        }
        
        header{
        background-color: black;
        font-family: Courier;
        }
        
        .homeButtons{
        /* position: absolute; */
        /* top: 32px; */
        /* right: 26px; */
        margin-top: 1%;
        font-size: 8px;
        }   
        
        .lineHeader, .lineFooter{
        /* margin-left: auto;
        margin-right: auto; */
        color: white;
        height: 3px;
        width: auto;
        {
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Stack Overflow</title>
        <link rel="stylesheet" href="style.css">
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    
    </head>
    <body>
        <header>
            <div class="d-flex justify-content-between">
                <a href="Website.html"><img id="smallLogo" src="/Users/ultimateorganism/Desktop/Brown-Dev-Proj-Vol.1/FuturUImages/smallLogo.png" alt="smallLogo"></a> 
                <h1 class="bizPage">FuturU</h1>
                <div class="homeButtons">
                    <a href="Website.html" class="btn btn-outline-light" id="linkHomePage">Home</a>
                    <a href="Mindmovies.html" class="btn btn-outline-light" id="linkMindMovies">MindMovies</a>
                    <a href="mailto:pbusko5@gmail.com?subject=I am interested in an affirmation/mindmap!" class="btn btn-outline-light" id="linkContact">Contact</a>
                    <a href="About.html" class="btn btn-outline-light" id="linkAbout">About</a>
                    <a href="Testimonials.html" class="btn btn-outline-light" id="linkTestimonials">Testimonials</a>
                    <hr style="background-color: white; height: 3px; opacity: initial;">
                </div>
            </div>
             <hr style="background-color: white; height: 3px; opacity: initial;">
           </header>
    
        <!-- <script type="text/javascript" src="index.js"></script>  -->
    </body>
    </html>

    让我知道它是否适合你。

    【讨论】:

    • 确实有帮助,但是为了兼容平板和手机,我觉得还是用汉堡包比较好。从现在开始使用它。
    猜你喜欢
    • 1970-01-01
    • 2016-04-17
    • 1970-01-01
    • 2023-03-07
    • 2018-07-09
    • 2014-09-26
    • 2019-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多