简体   繁体   English

引导程序对齐-导航头对齐

[英]Bootstrap alignment - nav header alignment

I am trying to achieve this: 我正在努力实现这一目标:

在此处输入图片说明

However, because I have an image, left aligned, and then two lines NEXT to the image (One is a H1 and one is a H2), I am battling to get the 'brand' box inside my nav bar. 但是,由于我有一个图像,该图像左对齐,然后在该图像的旁边有两行(一个是H1,一个是H2),因此我努力在导航栏中获取“品牌”框。 It seems to have a lot of padding and strange stuff going on. 似乎有很多填充和奇怪的东西正在进行。

在此处输入图片说明

This is my nav bar code: 这是我的导航条形码:

<div class="navbar navbar-inverse navbar-custom shadow_bottom navbar-fixed-top" role="navigation">
        <div class="container">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#small-navbar-button">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <div class="header">
                    <a class="navbar-brand" href="#">
                        <img src="~/images/logo.png" alt="AccuFinance - Home Budget Site" />
                    </a>

                    <a class="navbar-brand" href="#">

                        <h1>AccuFinance</h1>
                        <h2>Home Finance - Simplifying Budgeting</h2>
                    </a>
                </div>


            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="small-navbar-button" style="padding-right: 25px">
                <ul class="nav navbar-nav pull-right">
                    <li class="active"><a href="/"><span class="glyphicon glyphicon-home"></span>&nbsp;Home</a></li>

... ...

This issue is probably around my class="header" area. 这个问题可能与我的class =“ header”区域有关。 I have created some css to try and position my items correctly: 我创建了一些CSS来尝试正确放置我的物品:

.header img {
    float: left;
    margin: 2px;
    top: 5px;
    padding: 0;
}

.header h1 {
    position: relative;
    top: 5px;
    bottom: 2px;
    left: 2px;
}

But I can't seem to correctly align the two headers next to the image, WITHIN the navbar area. 但是我似乎无法在导航栏区域内正确对齐图像旁边的两个标题。

Bootply version: http://www.bootply.com/OzTmfYgHX7 Bootply版本: http//www.bootply.com/OzTmfYgHX7

The issue seems to be that my branding block (With the image and text) seems to have a large padding at the top. 问题似乎是我的品牌区(带有图片和文字)在顶部似乎有较大的填充。 The image should be right up against the top of the screen. 图像应正对屏幕顶部。

If you customize bootstrap: 如果您自定义引导程序:

http://getbootstrap.com/customize/ http://getbootstrap.com/customize/

Change the @navbar-height to something around 75px. 将@ navbar-height更改为75px左右。 That should do it for you. 那应该为你做。

By default bootstrap limits the height to 50px. 默认情况下,引导程序将高度限制为50px。 Any Brand images that are taller than that will overflow into the content below. 任何比该高的品牌图像都将溢出到下面的内容中。

You'll find that you are wrapping the logo image and logo text with the .navbar-brand class. 您会发现您正在使用.navbar-brand类包装徽标图像和徽标文本。

.navbar-brand {
  float: left;
  height: 50px;
  padding: 15px 15px;
  font-size: 18px;
  line-height: 20px;
}

So you could make a custom class based upon it and diddle the values to suit. 因此,您可以基于它创建一个自定义类,并添加适合的值。 Something like my-navbar-brand or whatever you like. 我的导航栏品牌之类的东西或您喜欢的任何东西。 Just having a quick play with it setting the padding to 5px 15px might be suitable. 只需将其填充设置为5px 15px就可以了。

.my-navbar-brand {
  float: left;
  height: 50px;
  padding: 5px 15px;
  font-size: 18px;
  line-height: 20px;
}

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

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