将导航div与响应式幻灯片的边缘对齐

时间:2015-01-13 21:18:30

标签: html css twitter-bootstrap responsive-design

目标是让上方导航的右边缘(导航栏右侧)与地址文本现在所处的图像幻灯片显示的右边缘对齐,而不会超出幻灯片显示的右边缘。

麻烦的是,地址div位于响应式幻灯片div中,允许它在网格大小改变时保持右对齐并且"快照"超过许多像素。有没有办法将上层导航集成到响应式网格中?#34; snapping"?

网站草稿:http://parkerrichard.com/studiogreen/html/parks.html

所需的路线:screen of desired alignenment

HTML:

<body>
<!-- row 1: static navbar -->
<nav class="navbar navbar-default navbar-top" 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 logo" href="index.html"><img class="logo" src="img/logo.png"></a>
        </div><!-- navbar toggle -->
        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right nav-stacked hidden-xs">
                <li><a href="process.html">PROCESS</a></li>
                <li><a href="office.html">OFFICE</a></li>
                <li><a href="contact.html">CONTACT</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right hidden-lg hidden-md hidden-sm mobile-nav">
                <li><a href="process.html">PROCESS</a></li>
                <li><a href="office.html">OFFICE</a></li>
                <li><a href="contact.html">CONTACT</a></li>
                <li class="divider"><img src="img/nav-divider.jpg"></li>
            </ul>
        </div><!--/nav-collapse -->
    </div><!--/container -->
</nav><!--/navbar -->

<!-- row 2: body -->
<div class="container">
    <div class="row centered">
        <!-- left sidebar -->
        <aside class="navbar-collapse collapse panel-group col-lg-4 col-med-5 col-sm-5 col-xs-12" id="accordion" role="tablist" aria-multiselectable="true">
            <div class="panel panel-default">
                <div class="panel-heading" role="tab" id="headingThree">
                    <h4 class="panel-title">
                        <a href="schools.html">
                            SCHOOLS
                        </a>
                    </h4>
                </div>
            </div>
        </aside>


        <!-- slideshow gallery -->          
        <div class="col-lg-8 col-md-7 col-sm-7 pull-left">
            <div class="flexslider no-arrow">
                <ul class="slides">
                    <li>
                        <img src="img/parks/img-01.jpg" />
                    </li>
                    <li>
                        <img src="img/parks/img-02.jpg" />
                    </li>
                </ul>
            </div>
            <address class="info-box temp-box temp-add pull-right">
            232 SIR FRANCIS DRAKE BLVD</br>
            SAN ANSELMO, CA 94960</br>
            415 721 0905
            </address>
        </div><!--/slideshow row -->
    </div><!--/body row -->
</div><!--/container -->

CSS:

    .container {
    width: 100%;
}

/* ==========================================================================
   General styles
   ========================================================================== */

html, body {
    overflow-x: hidden;
}

body {
    font-family: "proxima-nova", sans-serif;
    font-weight: 400;
    font-size: 11px;
    letter-spacing: .7px;
    color: #555;

    -webkit-font-smoothing: antialiased;
    -webkit-overflow-scrolling: touch;
}

aside {
    z-index: 100;
}

address {
    text-align: left;
    margin-bottom: 30px;
    display: none;
}

.info-box {
    text-align: left;
    font-weight: 400;
    padding: 0px 0px 0 55px;
    display: none;
}

/* ==========================================================================
   Navigation styles
   ========================================================================== */

/*
 * Top nav section
 */

.navbar-header {
    padding-bottom: 50px;
}

.navbar-brand {
    margin-left: 0px!important;
}

.navbar .nav {
    text-align: left;
    margin-top: 45px;
}

.navbar .nav > li {
    float: none;
    display: inline-block;
    font-size: 14px;
    letter-spacing: 2px;
    font-weight: 600;
}

.navbar-default {
    background-color: white;
    border-bottom: 0px;
}

.navbar-default .navbar-nav > li > a {
    color: #555;
}

.navbar-default .navbar-nav > li > a:hover, .navbar-default .navbar-nav > .active > a, .navbar-default .navbar-nav > .active > a:hover, .active > a, a:hover, a:active {
    color: #6CAA3D;
    background-color: transparent;
    text-decoration: none;
    outline: 0;
}

.navbar-default .navbar-nav > li {
    padding: 0px 15px 15px 0px;
}

.navbar-collapse {
    margin-top: -65px;
    border-top: 0px;
    border-color: none;
}

.navbar-default .navbar-collapse {
    padding-top: 10px;
    overflow-y: visible;
    padding-left: 115px;
}

.logo {
    margin-top: 10px;
    height: 100px;
    width: 200px;
}

.navbar-right {
    padding: 15px 20px 0 0;
    margin-right: 16%;
}

.mobile-nav {
    width: 100px;
}

/*
 * flexslider styling 
 */

.flexslider {
    background:none !important;
    border:none !important;
    box-shadow:none !important;
}

.slides li img {
    -moz-user-select: -moz-none;
    -khtml-user-select: none;
    -webkit-user-select: none;

    /*
     Introduced in IE 10.
     See http://ie.microsoft.com/testdrive/HTML5/msUserSelect/
    */
    -ms-user-select: none;
    user-select: none;
}

.flex-control-nav {
    text-align: right !important;
    padding-right: 0px !important;
}

.flex-control-paging li {
    margin: 0 0px 0 12px !important;
}

1 个答案:

答案 0 :(得分:0)

我将导航div移动到响应式幻灯片div并添加了一个新样式放置在右边缘。

更新了HTML:

<body>
    <!-- row 1: static navbar -->
    <nav class="navbar navbar-default navbar-top" 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 logo" href="index.html"><img class="logo" src="img/logo.png"></a>
            </div><!-- navbar toggle -->
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right hidden-lg hidden-md hidden-sm mobile-nav">
                    <li><a href="process.html">PROCESS</a></li>
                    <li><a href="office.html">OFFICE</a></li>
                    <li><a href="contact.html">CONTACT</a></li>
                    <li class="divider"><img src="img/nav-divider.jpg"></li>
                </ul>
            </div><!--/nav-collapse -->
        </div><!--/container -->
    </nav><!--/navbar -->

    <!-- row 1: body -->
    <div class="container">
        <div class="row centered">
            <!-- left sidebar -->
            <aside class="navbar-collapse collapse panel-group col-lg-4 col-med-5 col-sm-5 col-xs-12" id="accordion" role="tablist" aria-multiselectable="true">
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="headingThree">
                        <h4 class="panel-title">
                            <a href="schools.html">
                                SCHOOLS
                            </a>
                        </h4>
                    </div>
                </div>
            </aside>

            <!-- slideshow gallery -->
            <div class="col-lg-8 col-md-7 col-sm-7">
                <div class="navbar-collapse collapse plibt">
                    <ul class="nav navbar-nav navbar-right hidden-xs">
                        <li><a href="process.html">PROCESS</a></li>
                        <li><a href="office.html">OFFICE</a></li>
                        <li><a href="contact.html">CONTACT</a></li>
                    </ul>
                </div>
                <div class="flexslider nodot no-arrow pull-left">
                    <ul class="slides">
                        <li>
                            <img src="img/home-slideshow/img-01.jpg" />
                        </li>
                        <li>
                            <img src="img/home-slideshow/img-02.jpg" />
                        </li>
                    </ul>
                </div>
                <!-- address row -->
                <address class="info-box pull-right">
                232 SIR FRANCIS DRAKE BLVD</br>
                SAN ANSELMO, CA 94960</br>
                415 721 0905
                </address>
            </div><!--/slideshow row -->
        </div><!--/body row -->
    </div><!--/container -->

添加了CSS:

.plibt {
    position: absolute;
    right: 0;
    top: -150px;
    margin: 0 -22px 0px 0 !important;
    font-size: 14px;
    font-weight: 600;
    background: none;
}

.plibt li {
    padding: 15px 0px 15px 20px !important;
}

.plibt li a {
    background: none !important;
    letter-spacing: 2px;
}