无法使用波旁酒续杯



我正在尝试使用refills bourbon来使用他们的css库。据我所知,我所要做的就是复制和粘贴他们的css和html,它应该工作。但是当我尝试时,css没有生效。

我已经添加了链接到css文件,并添加了jquery链接,它仍然不工作。据我所知,当使用填充时,ruby是不必要的。如果我错过了任何步骤,请告诉我。谢谢。

HTML文件

<!DOCTYPE HTML>
<html>
    <head>
        <title></title>
        <link rel="stylesheet" href="styles.css">
        <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
        <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
    </head>
    <body>
        <header class="navigation">
          <div class="menu-wrapper">
            <a href="javascript:void(0)" class="logo">
              <img src="https://raw.github.com/Magnus-G/Random/master/placeholder_logo_1.png" alt="">
            </a>
            <p class="navigation-menu-button" id="js-mobile-menu">MENU</p>
            <div class="nav">
              <ul id="navigation-menu">
                <li class="nav-link"><a href="javascript:void(0)">Products</a></li>
                <li class="nav-link"><a href="javascript:void(0)">About Us</a></li>
                <li class="nav-link"><a href="javascript:void(0)">Contact</a></li>
                <li class="nav-link more"><a href="javascript:void(0)">More</a>
                  <ul class="submenu">
                    <li><a href="javascript:void(0)">Submenu Item</a></li>
                    <li><a href="javascript:void(0)">Another Item</a></li>
                  </ul>
                </li>
              </ul>
            </div>
            <div class="navigation-tools">
              <div class="search-bar">
                <div class="search-and-submit">
                  <input type="search" placeholder="Enter Search" />
                  <button type="submit">
                    <img src="https://raw.githubusercontent.com/Magnus-G/Random/master/search-icon.png" alt="">
                  </button>
                </div>
              </div>
              <a href="javascript:void(0)" class="sign-up">Sign Up</a>
            </div>
          </div>
        </header>
        <script>
          $(function() {
            var menu = $('#navigation-menu');
            var menuToggle = $('#js-mobile-menu');
            var signUp = $('.sign-up');
            $(menuToggle).on('click', function(e) {
              e.preventDefault();
              menu.slideToggle(function(){
                if(menu.is(':hidden')) {
                  menu.removeAttr('style');
                }
              });
            });
            // underline under the active nav item
            $(".nav .nav-link").click(function() {
              $(".nav .nav-link").each(function() {
                $(this).removeClass("active-nav-item");
              });
              $(this).addClass("active-nav-item"); 
              $(".nav .more").removeClass("active-nav-item");
            });
          });
        </script>
    </body>
</html>
CSS文件

header.navigation {
  $navigation-padding: 1em;
  $navigation-background: $dark-gray;
  $navigation-color: transparentize(white, 0.3);
  $navigation-color-hover: white;
  $navigation-height: 60px;
  $navigation-nav-button-background: $base-accent-color;
  $navigation-nav-button-background-hover: lighten($navigation-background, 10);
  $navigation-nav-button-border: 1px solid lighten($navigation-nav-button-background, 20);
  $navigation-search-background: lighten($navigation-background, 5);
  $navigation-search-border: 1px solid darken($navigation-background, 5);
  $navigation-active-link-color: transparentize(white, 0.5);
  $navigation-submenu-padding: 1em;
  $horizontal-bar-mode: $large-screen;
  background-color: $navigation-background;
  border-bottom: 1px solid darken($navigation-background, 10);
  font-family: $sans-serif;
  height: $navigation-height;
  width: 100%;
  z-index: 999;
  .menu-wrapper {
    @include outer-container;
    @include clearfix;
    position: relative;
    z-index: 9999;
  }
  .logo {
    float: left;    
    max-height: $navigation-height;
    padding-left: $navigation-padding;
    padding-right: 2em;
    img {
      max-height: $navigation-height;
      padding: .8em 0;
    }
  }
  .navigation-menu-button {
    color: $navigation-color;
    cursor: pointer;
    display: block;
    float: right;
    font-family: $sans-serif;
    font-weight: 700;
    line-height: $navigation-height;
    margin: 0;
    padding-right: 1em;
    text-transform: uppercase;
    @include media ($horizontal-bar-mode) {
      display: none;
    }
    &:hover {
      color: $navigation-color-hover;
    }
  }
  .nav {
    z-index: 9999999;
    float: none;
    @include media ($horizontal-bar-mode) {
      float: left;
    }
  }
  ul#navigation-menu {    
    clear: both;
    -webkit-transform-style: preserve-3d; // stop webkit flicker
    display: none;
    margin: 0 auto;
    overflow: visible;
    padding: 0;
    width: 100%;
    z-index: 9999;
    @include media ($horizontal-bar-mode) {
      display: inline;
      margin: 0;
      padding: 0;
    }
  }
  ul li {
    background: $navigation-background;
    display: block;
    line-height: $navigation-height;
    overflow: hidden;
    padding-right: .8em;
    text-align: right;
    width: 100%;
    z-index: 9999;
    @include media ($horizontal-bar-mode) {
      background: transparent;
      display: inline;
      line-height: $navigation-height;
      padding-right: 2em;
      text-decoration: none;
      width: auto;
    }
    a {
      font-weight: 400;
      color: $navigation-color;
      &:hover {
        color: $navigation-color-hover;
      }
    }
  }
  .active-nav-item a {
    padding-bottom: 3px;
    border-bottom: 1px solid $navigation-active-link-color;
  }
  li.more {
    padding-right: 0;
    &:hover .submenu {
      display: block;
    }
    @include media($horizontal-bar-mode) {
      position: relative;
      padding-right: .8em;
    }
  }
  li.more a {
    padding-right: .8em;
  }
  .submenu {
    display: none;
    @include media($horizontal-bar-mode) {
      position: absolute;
      top: 1em;
      left: -$navigation-submenu-padding;
    }
    li {
      display: block;
      padding-right: 0;
      @include media($horizontal-bar-mode) {
        line-height: $navigation-height /1.3;
        &:first-child a {
          padding-top: 1em;
        }
        &:last-child a {
          border-bottom-left-radius: $base-border-radius;
          border-bottom-right-radius: $base-border-radius;
          padding-bottom: .7em;
        }
      }
      a {
        text-align: right;
        background-color: darken($navigation-background, 3);
        width: 100%;
        display: inline-block;
        @include media($horizontal-bar-mode) {
          width: 12em;
          background-color: $navigation-background;
          text-align: left;
          padding-left: $navigation-submenu-padding;
        }
      }
    }
  }
  .navigation-tools {
    @include clearfix;
    display: block;
    padding-right: $navigation-padding;
    padding-left: $navigation-padding/2;
    clear: both;
    background: #505050;
    @include media($large-screen) {
      background: transparent;
      float: right;
      clear: none;
    }
  }
  a.sign-up {
    margin-top: 13px;
    float: right;
    @include transition (all 0.2s ease-in-out);
    display: inline;
    background: $navigation-nav-button-background;
    border-radius: $base-border-radius; 
    color: white;
    font-size: .8em;  
    font-weight: 800;
    text-transform: uppercase;
    padding: .4em .5em;
    @include media($large-screen) {
      padding: .4em 1em;
    }
    &:hover {
      background: lighten($navigation-nav-button-background, 10);
    }
  }
  .search-bar {
    $search-bar-border-color: $base-border-color;
    $search-bar-border: 1px solid $search-bar-border-color;
    $search-bar-background: lighten($search-bar-border-color, 10);
    padding: 13px 5px; 
    float: left;
    .search-and-submit {
      position: relative;
      input[type=search] {
        background: $navigation-search-background;
        border: $navigation-search-border;
        padding: .6em .8em;
        font-size: .9em;
        font-style: italic;
        color: $navigation-color;
        border-radius: $base-border-radius * 2;
        margin: 0;
      }
      button[type=submit] {
        @include button(simple, lighten($navigation-search-background, 10));
        @include position(absolute, 0.3em 0.3em 0.3em 0);
        outline: none;
        padding: 5px 15px;
        img {
          height: 12px;
          opacity: .7;
        }
      }
    }
    @include media($horizontal-bar-mode) {
      width: 16em;
      position: relative; 
      display: inline-block;
      input {
        @include box-sizing(border-box);
        display: block;
      }
    }
  }
}

您给出的示例CSS实际上是*S*CSS。

Bourbon/Neat/Refills是SASS/SCSS库的集合。因此,波旁网站上给出的示例是用SCSS而不是CSS编写的。你可以使用一个预编译器,比如compass自带的预编译器,从你给出的例子中生成CSS,然后你就可以在你的html中链接到它。

必须取消_base中的line10注释。Scss,使用neat时默认不包含_grid设置。还要检查_grid-settings。在第一行导入SCSS文件。

这对我有用。

什么对我有效(meta viewport)

伙计,我花了很长时间才发现这个。

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

果然奏效了。


关于Sass

小心填充,正如Ian Wootten所说,这不是CSS,这是SCSS,所以你必须编译它来生成CSS。最简单的方法是签出http://sass-lang.com/install

安装Sass,然后使用命令生成HTML(编译)

sass --watch input.scss:output.css

按照这里的完整说明:使用sass docs

相关内容

  • 没有找到相关文章