代码之家  ›  专栏  ›  技术社区  ›  Arthak

导航栏上的登录按钮不合适

  •  0
  • Arthak  · 技术社区  · 8 年前

    我为我的应用程序制作了一个导航栏,并为它实现了登录按钮,但它向右移动,显示不正确,我已经尝试过更改填充和边距,但没有帮助。

    Navbar before login

    Navbar after login

    我在成功登录时隐藏并显示div。我怎样才能正确地插入它,使它以一种体面的方式显示出来,而不会从右边逃走。此外,任何关于在导航栏后面添加任何颜色的建议都将受到欢迎。

    /* GLOBAL STYLES
    -------------------------------------------------- */
    /* Padding below the footer and lighter body text */
    
    body {
      color: #5a5a5a;
    }
    
    /* CUSTOMIZE THE NAVBAR
    -------------------------------------------------- */
    
    /* Special class on .container surrounding .navbar, used for positioning it into place. */
    .navbar-wrapper {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      z-index: 20;
    }
    .alignr{
      margin-right: 20px;
    }
    
    /* Flip around the padding for proper display in narrow viewports */
    .navbar-wrapper .container {
      padding-left: 0;
      padding-right: 0;
    }
    .navbar-wrapper .navbar {
      padding-left: 15px;
      padding-right: 15px;
    }
    
    
    /* CUSTOMIZE THE CAROUSEL
    -------------------------------------------------- */
    
    /* Carousel base class */
    #mainCarousel .carousel {
      height: 450px;
      interval: 1000;
    }
    /* Since positioning the image, we need to help out the caption */
    #mainCarousel  .carousel-caption {
      z-index: 10;
    }
    
    /* Declare heights because of positioning of img element */
    #mainCarousel  .carousel .item {
      height: 450px;
      background-color: #777;
    }
    #mainCarousel  .carousel-inner > .item > img {
      position: absolute;
      top: 0;
      left: 0;
      min-width: 100%;
      height: 450px;
    }
    
    
    /* MARKETING CONTENT
    -------------------------------------------------- */
    #firebaseui-auth-container{
      padding: 0 auto;
      margin-top: 0;
      margin-bottom: 0;
      max-height: 15px;
    
    }
    
    
    .dropdown-toggle{
      padding: 0 auto;
      margin-top: 0;
      margin-bottom: 0;
      max-height: 15px;
    }
    
    /* Pad the edges of the mobile views a bit */
    .marketing {
      padding-left: 15px;
      padding-right: 15px;
    }
    
    /* Center align the text within the three columns below the carousel */
    .marketing .col-lg-4 {
      text-align: center;
      margin-bottom: 20px;
    }
    .marketing h2 {
      font-weight: normal;
    }
    .marketing .col-lg-4 p {
      margin-left: 10px;
      margin-right: 10px;
    }
    
    
    /* Featurettes
    ------------------------- */
    
    .featurette-divider {
      margin: 80px 0; /* Space out the Bootstrap <hr> more */
    }
    
    /* Thin out the marketing headings */
    .featurette-heading {
      font-weight: 300;
      line-height: 1;
      letter-spacing: -1px;
    }
    
    
    /* Custom CSS =========================================== */
    .navbar-inverse {background-color: #efefef; border-color: #FF5200;}
    .navbar-inverse .navbar-nav>.open>a, .navbar-inverse .navbar-nav>.open>a:hover, .navbar-inverse .navbar-nav>.open>a:focus,
    .navbar-inverse .navbar-nav>.active>a, .navbar-inverse .navbar-nav>.active>a:hover, .navbar-inverse .navbar-nav>.active>a:focus {color: #fff; background-color: #c83a3a;}
    .navbar-inverse .navbar-toggle:hover, .navbar-inverse .navbar-toggle:focus {background-color: #e4dcd2;}
    .navbar-inverse .navbar-toggle {border-color: #c83a3a;}
    .navbar-inverse .navbar-nav > li > a{color:#000}
    .navbar-inverse .navbar-nav > li > a:hover, .navbar-inverse .navbar-nav > li > a:focus{color:#C83A3A}
    a{color:#fff}
    a:hover{color:#eee}
    .marketing img{max-width:100%}
    .carousel-caption {color: #000000;}
    .carousel-caption  h1{background-color: #eb4800;color: #fff;display:inline-block;padding:4px 18px; width: auto;-ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=80)';opacity: 0.8;}
    .dsc {background-color: #757575;color: #fff;display: inline-block;padding: 4px 18px; width: auto;-ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=80)';opacity: 0.8;}
    .highlightSection{padding:28px 0}
    .highlightSection img{padding:0 0 28px 0}
    .highlightSection .media{background-color: #efefef;border: 1px solid #efefef;color: #939393;padding: 10px;text-align: center;}
    .introSection{background-color: #efefef; padding:28px 0}
    .brandBtn{background-color: #7db641;}
    .btn-default{color: #fff;background-color: #7db641;border-color: #7db641;border-radius:0}
    .btn-default.active, .open .dropdown-toggle.btn-default, .btn-default:hover, .btn-default:focus, .btn-default:active {color: #fff;background-color: #c83a3a ;border-color: #c83a3a ;}
    .text-primary-theme {color: #7db641;}
    .text-danger-theme {color: #FF007A;}
    .carousel-control.right, .carousel-control.left,
    #myCarousel1 .carousel-control.right, #myCarousel1 .carousel-control.left,
    #myCarousel2 .carousel-control.right, #myCarousel2 .carousel-control.left {background: none;color: #057C00;font-size: 3em; width: 6%;}
    .itemsTitle{border-bottom: 1px solid #e7e7e7;padding: 8px 30px;font-size: 20px;text-transform: uppercase;position: relative;margin-bottom: 20px;text-align:center}
    #myCarousel .container{padding:0}
    #mainCarousel .carousel .item {height: 450px;background-color: #FFF;}
    footer{padding:18px 0; background:#111; color:#fff;}
    .marketing{padding:28px 0}
    .pageTitle{padding:18px 0; border-top:1px solid #efefef; margin-top:92px; background:#efefef}
    .pageTitle h2{padding:0; margin:0}
    .bodyInner{padding:28px 0}
    .carousel-caption {bottom: 61px;}
    .mainTitle {padding: 4px 0;border-top: 1px solid #FF8500;background: #FAFAFA;color: #0C0C0C;text-align: center;box-shadow: 0 0 24px #D5D5D5;}
    .cntr{text-align:center}
    
    /* RESPONSIVE CSS
    -------------------------------------------------- */
    
    @media (min-width: 768px) {
    
      /* Remove the edge padding needed for mobile */
      .marketing {
        padding-left: 0;
        padding-right: 0;
      }
      /* Navbar positioning foo */
      .navbar-wrapper {
        margin-top: 20px;
      }
      .navbar-wrapper .container {
        padding-left:  15px;
        padding-right: 15px;
      }
      .navbar-wrapper .navbar {
        padding-left:  0;
        padding-right: 0;
      }
    
      /* The navbar becomes detached from the top, so we round the corners */
      .navbar-wrapper .navbar {
        border-radius: 4px;
      }
    
      /* Bump up size of carousel content */
      .carousel-caption p {
        margin-bottom: 20px;
        font-size: 21px;
        line-height: 1.4;
      }
    
      .featurette-heading {
        font-size: 50px;
      }
    
    }
    
    @media (min-width: 992px) {
      .featurette-heading {
        margin-top: 120px;
      }
    }
    <!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">
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="shortcut icon" href="themes/assets/ico/favicon.ico">
        <title>Bazinga</title>
        <script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
        <!-- Bootstrap core CSS -->
        <link href="themes/dist/css/bootstrap.min.css" rel="stylesheet">
        <link href="themes/assets/css/carousel.css" rel="stylesheet">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
      </head>
    <!-- NAVBAR
    ================================================== -->
      <body>
        <div class="navbar-wrapper">
          <div class="container">
    
            <div class="navbar navbar-inverse navbar-static-top navbar navbar-dark bg-dark" role="navigation">
              <div class="container">
                <div class="navbar-header">
                  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                  </button>
                  <a class="navbar-brand" href="index.html">Bazinga</a>
                </div>
                <div class="navbar-collapse collapse">
                  <ul class="nav navbar-nav">
                    <li class="active"><a href="index.html">Home</a></li>
                    <li><a href="about.html" >About Us</a></li>
                    <li><a href="contact.html">Contact</a></li>
                  </ul>
                  <div class="container">
                  <ul class="nav navbar-nav navbar-right">
                      <li>
                      <button type="button" class="btn btn-primary" id="glogin" onclick="signIn();"><i class="fa fa-google-plus"></i>Sign-In With Google</button>
                    </li>
                      <li class="dropdown">
                      <a href="#" class="dropdown-toggle welcome" id = "hellow" data-toggle="dropdown"><b class="caret"></b></a>
                      <ul class="dropdown-menu logind">
                        <li><a href="#">My Orders</a></li>
                        <li><a href="#">My Address</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="#">Signout</a></li>
                      </ul>
                    </li>
                    </li>
                      </ul>
                    </li>
                  </ul>
                </div>
              </div>
            </div>
    
          </div>
        </div>

    编辑1:如果需要更多代码,可以在此处看到托管副本 link

    编辑2:根据建议 Ash 以下代码将其居中为 here 但它仍处于边缘,我也尝试了正确的利润率:90像素,但没有帮助。

    .navbar-right{
    margin-right:45px;
    line-height:48px;
    }
    
    1 回复  |  直到 8 年前
        1
  •  0
  •   Ash    8 年前

    希望这会有所帮助

    .navbar-right{
    margin-right:45px;
    line-height:48px;
    }
    
    推荐文章