Html - 活动标签不会更改

时间:2014-01-19 08:57:44

标签: javascript html css

我正在处理管理信息中心,我正在查看以下示例: http://pixaza.com/40-free-login-and-contact-form-in-css-html/#

CSS看起来像这样:

*, html, body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4,

h5, h6, pre, form, label, fieldset, input, p, blockquote, th, td {

    margin: 0;

    padding: 0;

}



table {

    border-collapse: collapse;

    border-spacing: 0;

}



fieldset, img { border: 0; }



address, caption, cite, code, dfn, em, strong, th, var {

    font-style: normal;

    font-weight: normal;

}



caption, th { text-align: left; }



h1, h2, h3, h4, h5, h6 { font-weight: normal; }



q:before, q:after { content: ''; }



strong { font-weight: bold; }



em { font-style: italic; }



a img { border: none; } /* Gets rid of IE's blue borders */



a { text-decoration: none; }



body { font-size: 1em; /* Prevents an IE bug where em's scale out of proportion */ }











/* ---------- CLEARFIX ---------- */

/* For modern browsers */

.cf:before,

.cf:after {

    content: "";

    display: table;

}



.cf:after { clear:both; }



/* For IE 6/7 (trigger hasLayout) */

.cf { zoom: 1; }











/* ---------- GENERAL ---------- */

.round {

    border-radius: 0.3125em; /* 5/16 */

    -moz-border-radius: 0.3125em; /* 5/16 */

    -webkit-border-radius: 0.3125em; /* 5/16 */

}



p {

    margin-bottom: 1.25em; /* 20/16 */

    color: #9498a1;

}



.fl { float: left; }

.fr { float: right; }

.cb { clear: both; }



.half-size-column {

    width: 48%;

}



div.stripe-separator {

    background: transparent url('separator-bg.png') repeat-x left center;

    height: 0.562em; /* 9/16 */

    display: block;

    margin: 1.25em 0; /* 20/16 */

}



h1, h2, h3, h4, h5, h6 { margin-bottom: 0.625em; /* 10/16 */ }



/*Temporary styles*/

ul.temporary-button-showcase {

    list-style-type: none;

}



    ul.temporary-button-showcase li {

        width: 24%;

        float: left;

        margin-bottom: 1em;

    }



code {

    display: inline-block;

    background-color: #f8f9fa;

    border: 1px solid #eeefef;

    padding: 0.416em 0.833em; /* 5/12 10/12 */

    color: #2a2e36;

}



blockquote {

    display: block;

    font-style: italic;

    border-left: 2px solid #eeefef;

    padding-left: 0.833em; /* 10/12 */

    color: #9498a1;

}



cite {

    font-style: italic;

    font-weight: bold;

    display: block;

    padding-left: 0.833em; /* 10/12 */

    margin-top: 0.833em; /* 10/12 */

    color: #9498a1;

}













/* ---------- TYPOGRAPHY ---------- */

body, form {

    font-family: "Droid Sans", Helvetica, Arial, sans-serif;

    line-height: 1.125em; /* 18/16 */

}



p, .button, form input, ul#nav li ul, ul#tabs, div.side-menu ul li a, table,

.information-box, .confirmation-box, .error-box, .warning-box, ol, .regular-ul,

.custom-ul, blockquote, cite { font-size: 0.75em; /* 12/16 */ }



div.content-module-heading span { font-size: 0.625em; /* 10/16 */ }



form p input[type="text"], form p input[type="password"], form p input[type="checkbox"], form p input[type="radio"] { font-size: 1em; /* 12/12. I did 12 because they're contained within a P tag, that has font size of 12px*/ }



h1 { font-size: 1.125em; /* 18/16 */ }

h2 { font-size: 0.875em; /* 14/16 */ }

h3 { font-size: 0.75em; /* 12/16 */ }

h4 { font-size: 0.685em; /* 11/16 */ }

h5 { font-size: 0.625em; /* 10/16 */ }


/* ---------- COLORS ---------- */

a { color: #2069b4; }

    a:hover { color: #2a2e36; }



p a, p a:hover { border-bottom: 1px dotted; }



.blue {

    background-color: #2069b4;

    color: white;

}

    .blue:hover {

        background-color: #5081b3;

        color: white;

    }











/* ---------- WIDTHS ---------- */

/* Form Inputs Style */

.default-width-input { width: 20.833em; /* Default Value. Equals 250px for the 12px font size */ }



.full-width-input { width: 95%; }



/* Textarea Style */

.full-width-textarea {

    width: 95%;

    height: 12.5em; /* 150/12 */

}



/* Page Container Style */

.page-full-width { padding: 0 1.875em; /* 30/16 */ }



.page-limited {

    width: 60em; /* 960/16 */

    margin: 0 auto;

}











/* ---------- BUTTONS ---------- */

.button {

    padding: 0.833em; /* 10/12 */



    display: inline-block;

    text-decoration: none;

    background-repeat: no-repeat;

}



.dark {

    background-color: #3f4551;

    color: white;

}

    .dark:hover {

        background-color: #5d6677;

        color: white;

    }



.text-upper { text-transform: uppercase; }



.small-button { padding: 0.312em 1em; /* 5/16 16/16 */ }



.image-left {

    background-position: 0.833em center; /* 10/12 */

    padding-left: 3em; /* 36/12 */

}



.image-right {

    background-position: right center;

    padding-right: 3em; /* 36/12 */

}



.ic-left-arrow { background-image: url("icons/ic_left.png"); }

.ic-right-arrow { background-image: url("icons/ic_right.png"); }

.ic-print { background-image: url("icons/ic_print.png"); }

.ic-cancel { background-image: url("icons/ic_cancel.png"); }

.ic-delete { background-image: url("icons/ic_delete.png"); }

.ic-add { background-image: url("icons/ic_add.png"); }

.ic-download { background-image: url("icons/ic_download.png"); }

.ic-edit { background-image: url("icons/ic_edit.png"); }

.ic-favorite { background-image: url("icons/ic_favorite.png"); }

.ic-lock { background-image: url("icons/ic_lock.png"); }

.ic-power { background-image: url("icons/ic_power.png"); }

.ic-refresh { background-image: url("icons/ic_refresh.png"); }

.ic-settings { background-image: url("icons/ic_settings.png"); }

.ic-upload { background-image: url("icons/ic_upload.png"); }

.ic-search { background-image: url("icons/ic_zoom.png"); }



.ic-table-edit { background-image: url("icons/table/actions-edit.png"); }

.ic-table-delete { background-image: url("icons/table/actions-delete.png"); }





/* ---------- MENU BUTTONS ---------- */

.menu-email { background-image: url("icons/menu/menu-email.png"); }

    .menu-email:hover { background-image: url("icons/menu/menu-email-over.png"); }

    .menu-email-special {

        background-image: url("icons/menu/menu-email-special.png");

        color: #7fcdff;

    }



.menu-settings { background-image: url("icons/menu/menu-settings.png"); }

    .menu-settings:hover { background-image: url("icons/menu/menu-settings-over.png"); }



.menu-logoff { background-image: url("icons/menu/menu-logoff.png"); }

    .menu-logoff:hover { background-image: url("icons/menu/menu-logoff-over.png"); }



.menu-user { background-image: url("icons/menu/menu-user.png"); }







/* ---------- FORMS ---------- */

form label {

    display: block;

    text-transform: uppercase;

    color: #2a2e36;

    margin: 0 0 0.3125em 0;

}



form label.alt-label { text-transform: none; }



form input[type="text"], input[type="password"], textarea {

    border: 1px solid #d9dbdd;

    padding: 1em 0.625em; /* 16/16 10/16 */

    outline: none;

}

    form input[type="text"]:hover, input[type="password"]:hover, textarea:hover,

    form input[type="text"]:focus, input[type="password"]:focus, textarea:focus {

        border: 1px solid #bbbdbe;

    }



form input[type="checkbox"], form input[type="radio"] { margin-right: 0.833em; /* 10/12 */ }



form input[type="submit"] {

    border: none;

    cursor: pointer;

    padding: 0.833em; /* 10/12 */



    background-position: right center;

    padding-right: 3em; /* 36/12 */

    background-repeat: no-repeat;

    font-weight: bold;

    text-transform: uppercase;

}



form#search-form input {

    border: none;

    /* The inner text overflows on the BG image, so we're setting a right padding to stop that */

    padding-right: 3em; /* 36/12 */

}

    form#search-form input:focus {

        /* Same as .dark:hover */

        background-color: #5d6677;

        color: white;

    }



form p em {

    margin-top: 0.833em; /* 10/12 */

    display: block;

}



form p.form-error, form p.form-error label { color: #cf4425; }



form p.form-error em {

    background: transparent url('icons/message-boxes/error.png') no-repeat left center;

    padding-left: 2em; /* 24/12 */

}



form input.error-input { border: 1px solid #ff876f; }

    form input.error-input:hover { border: 1px solid #b03e27; }



/* Styling the HTML5 placeholders */

/* So far they don't work in: IE, Opera 10 and below, Firefox 3.6 and below */

::-webkit-input-placeholder { color: #858d9c; }

:-moz-placeholder { color: #858d9c; }











/* ---------- CONTENT BOXES ---------- */

.information-box, .confirmation-box, .error-box, .warning-box {

    padding: 0.833em 0.833em 0.833em 3em; /* 10/12 36/12 */

    margin-bottom: 0.833em; /* 20/12 */

}



.information-box {

    background: #e5f5f9 url('icons/message-boxes/information.png') no-repeat 0.833em center;

    border: 1px solid #cae0e5;

    color: #5a9bab;

}



.confirmation-box {

    background: #e7fae6 url('icons/message-boxes/confirmation.png') no-repeat 0.833em center;

    border: 1px solid #b7cbb6;

    color: #52964f;

}



.error-box {

    background: #fde8e4 url('icons/message-boxes/error.png') no-repeat 0.833em center;

    border: 1px solid #e6bbb3;

    color: #cf4425;

}



.warning-box {

    background: #fdf7e4 url('icons/message-boxes/warning.png') no-repeat 0.833em center;

    border: 1px solid #e5d9b2;

    color: #b28a0b;

}











/* ---------- MENU ---------- */

ul#nav {

    list-style-type: none;

}



    ul#nav > li {

        float: left;

        margin-right: 0.312em; /* 5/16 */

        position: relative;

    }

        ul#nav li:first-child { margin-left: 0; }

        ul#nav li:hover ul { left: 0; /* On hover, we make the submenu visible again */ }

        /* Persistent hover state, exactly the same style as the inner anchor on hover (.dark:hover) */

        ul#nav li:hover a {

            background-color: #5d6677;

            color: white;

        }

    ul#nav li.v-sep {

        border-right: 1px solid #3f4551;

        margin-right: 0.625em; /* 10/16 */

        padding-right: 0.625em; /* 10/16 */

    }



    ul#nav li ul {

        list-style-type: none;

        position: absolute;

        z-index: 999;

        margin-top: -2px;

        left: -9999px;

    }

        ul#nav li ul li a {

            color: white;

            padding: 0.833em 0 0.833em 3em;

            border-top: 1px solid #6a7282;

            background: #5d6677 url('menu-indicator.png') no-repeat right center;

            display: block;

            width: 100%;

            white-space: nowrap;

        }

            ul#nav li ul li:last-child a {

                border-bottom-right-radius: 0.3125em; /* 5/16 */

                border-bottom-left-radius: 0.3125em; /* 5/16 */

                -moz-border-bottom-right-radius: 0.3125em; /* 5/16 */

                -moz-border-bottom-left-radius: 0.3125em; /* 5/16 */

                -webkit-border-bottom-right-radius: 0.3125em; /* 5/16 */

                -webkit-border-bottom-left-radius: 0.3125em; /* 5/16 */

            }



            ul#nav li ul li a:hover { background-color: #7a8497; }


/* ---------- TOP + HEADER ---------- */

div#top-bar {

    background-color: #2a2e36;

    padding: 0.625em 0; /* 10/16 */

}



div#header { padding: 1.25em 0; /* 20/16 */ }



div#header-with-tabs { padding: 1.25em 0 0 0; /* 20/16 */ }



div#login-intro {

    background: transparent url('login-icon.png') no-repeat left center;

    padding: 0.312em 0 0.312em 3.125em;

}

    div#login-intro h1 { text-transform: uppercase; margin: 0.312em 0 0 0; }

    div#login-intro h5 { color: #9498a1; }



a#company-branding img { height: 39px; }

a#company-branding-small img { height: 30px; }


/* ---------- TABS ---------- */

ul#tabs { list-style-type: none; }



    ul#tabs li { float: left; }



        ul#tabs li a {

            border: 1px solid #eeefef;

            border-bottom: none;

            padding: 1.666em 0.833em; /* 20/12 10/12 */

            margin: 0 0.416em -1px 0;

            display: block;

            color: #9498a1;

        }

            ul#tabs li a:hover { color: #2a2e36; }



ul#tabs li a.dashboard-tab {

    background: transparent url('tab-dashboard.png') no-repeat 0.833em center /* 10/12 */;

    padding-left: 3em; /* 36/12 */

}


ul#tabs li a.active-tab, ul#tabs li a.active-tab:hover {

    background-color: #f8f9fa;

    font-weight: bold;

    color: #2a2e36;

}


/* ---------- TABLES ---------- */

table { width: 100%; margin-bottom: 1.25em; /* 20/16 */ }



    table th {

        background-color: #5d6677;

        color: white;

        text-transform: uppercase;

        padding: 1.25em 0 1.25em 1.25em; /* 15/12 */

        border-left: 1px solid #747c8a;

    }



    table tbody td {

        padding: 0.833em 0 0.833em 1.25em; /* 10/12 15/12 */

        border-left: 1px solid white;

        border-bottom: 1px solid #f8f9fa;

    }

    /* Alternate table row */

    table tbody tr:nth-child(odd) { background-color: #f8f9fa; }



    /* Push the first cell to the right so it doesn't stick to the table border */

    table td:first-child, table th:first-child {

        width: 4em /* 48/12 */;

        text-align: center;

        padding: 0;

        border: none;

        border-bottom: 1px solid #f8f9fa;

    }



    table td:last-child, table th:last-child {

        width: 7em; /* 84/12 */

        text-align: center;

        padding: 0;

    }

    table td.table-footer {

        text-align: left;

        vertical-align: middle;

        padding-top: 1.25em /* 15/12 */;

        border: none;

    }



a.table-actions-button {

    width: 1.25em;

    height: 1.25em;

    display: inline-block;

    background-position: center center;

}


/* ---------- LISTS ---------- */

ol li, .regular-ul li { margin-left: 1.25em; /* 20/16 */ }



ol, .regular-ul, .custom-ul { margin-bottom: 1.25em; /* 20/16 */ }



.custom-ul { list-style-type: none; }



    .custom-ul li {

        background: transparent url('menu-dark-indicator.png') no-repeat left center;

        padding-left: 1.25em /* 10/12 */;

    }


/* ---------- CONTENT ---------- */

div#content {

    background: #f8f9fa url('artwork-pattern.png') repeat-x left bottom;

    border: 1px solid #eeefef;

    padding: 1.875em 0; /* 30/16 */

}

form#login-form {

    width: 18.75em; /* 300/16 */

    margin: 0 auto;

}



div.side-menu {

    background: #3f4551;

    border: 1px solid #eeefef;

    width: 15%;

    margin-bottom: 1em; /* 16/16 */

}



    div.side-menu h3 {

        text-transform: uppercase;

        font-weight: bold;

        margin:  1.25em; /* 15/12 */

        color: white;

    }



    div.side-menu ul { list-style-type: none; }



        div.side-menu ul li a {

            padding: 0.833em 1.25em; /* 10/12 15/12 */

            border-top: 1px solid #f8f9fa;

            display: block;

            background: white url('menu-dark-indicator.png') no-repeat right center;

        }

            div.side-menu ul li a:hover {

                background-color: #f8f9fa;

            }



div.side-content { width: 83%; /* 100% - 15% for the side menu - 2% for the left margin */ }



div.content-module {

    background: white;

    margin-bottom: 1em; /* 16/16 */

    border: 1px solid #eeefef;

}



div.content-module-heading {

    background: #3f4551;

    cursor: pointer;

}



    div.content-module-heading h3 {

        text-transform: uppercase;

        color: white;

        font-weight: bold;

        margin: 1.25em; /* 15/12 */

    }



    div.content-module-heading span {

        color: #969dac;

        text-transform: uppercase;

        margin: 1.5em; /* 15/10 */

    }



div.content-module-main { padding: 1em; /* 16/16 */ }


/* ---------- FOOTER ---------- */

div#footer {

    text-align: center;

    padding: 1.875em 0; /* 30/16 */

}

application.html.erb:

<!DOCTYPE html>

<html lang="en">

  <head>

    <!-- Stylesheets -->

    <link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet'>

    <link rel="stylesheet" href="/assets/application.css">



    <!-- Optimize for mobile devices -->

    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>



  <!-- jQuery & JS files -->

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>

  <script src="/assets/script.js"></script>

  </head>



  <body>

    <!-- TOP BAR - Only if user has authenticated -->

  <% if current_user %>

  <div id="top-bar">



    <div class="page-full-width cf">



    <ul id="nav" class="fl">



      <li class="v-sep"><a href="#" class="round button dark menu-user image-left">Logged in as <strong><%= current_user.name %></strong></a>

      </li>

      <li><%= link_to "Sign Out", signed_out_path, :class => "round button dark menu-logoff image-left" %></li>



    </ul> <!-- end nav -->





      <form action="#" method="POST" id="search-form" class="fr">

        <fieldset>

          <input type="text" id="search-keyword" class="round button dark ic-search image-right" placeholder="Search..." />

          <input type="hidden" value="SUBMIT" />

        </fieldset>

      </form>



    </div> <!-- end full-width -->



  </div> <!-- end top-bar -->



  <!-- HEADER -->

  <div id="header-with-tabs">

    <div class="page-full-width cf">

      <ul id="tabs" class="fl">

        <li><a href="dashboard.html" class="dashboard-tab">Dashboard</a></li>

        <li><a href="../er_queues" >Full width page</a></li>

        <li><a href="page-other.html" class="active-tab">Other page elements</a></li>

      </ul> <!-- end tabs -->

    </div> <!-- end full-width -->

  </div> <!-- end header -->

  <% end %>



  <%= yield %>



  </body>

我正在使用rails,而我只使用上面的css。 现在,我将所有选项卡代码放在application.html.erb上,由于某种原因,单击的选项卡未突出显示,并且初始活动选项卡未更改(我正在查看页面的来源,我看到了class =“active-tab”仍然在旧选项卡上,虽然我在另一页上。 任何人都可以看到原因吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

您需要在其他页面上设置class =“active-tab”属性。 因此,在您当前的页面中,您可以使用page-other.html:

<li><a href="dashboard.html" class="dashboard-tab">Dashboard</a></li>

<li><a href="../er_queues" >Full width page</a></li>

<li><a href="page-other.html" class="active-tab">Other page elements</a></li>

所以在er_queues页面中:

<li><a href="dashboard.html" class="dashboard-tab">Dashboard</a></li>

<li><a href="../er_queues" class="active-tab">Full width page</a></li>

<li><a href="page-other.html">Other page elements</a></li>

在dashboard.html页面中:

<li><a href="dashboard.html" class="dashboard-tab" class="active-tab">Dashboard</a></li>

<li><a href="../er_queues" >Full width page</a></li>

<li><a href="page-other.html">Other page elements</a></li>

您可以注意到相应的样式(class =“active-tab”)是为它们各自页面中对应的页面设置的。

希望这能解决你的问题。