2

这是我的 Bootstrap Tour 正在处理的 HTML:

<body class="top-navigation">
   <div id="wrapper">
      <div id="page-wrapper">
        <div class="row border-bottom">
          <nav class="navbar navbar-static-top">
             <div class="navbar-header">
               <a href="/">
                 <img class="navbar-brand" alt="image" src="logo.png" />
               </a>
               <form class="navbar-form-custom" action="/profiles" accept-charset="UTF-8" method="get">
                  <input type="text" name="q" id="top-search" class="form-control"/>
               </form>    
             </div>

         <ul class="nav navbar-top-links navbar-right">
              <li>
                <a class="coach-dashboard" href="/dashboard">
                  <i class="fa fa-dashboard"></i> My Dashboard
                </a>              
              </li>
              <li>
                <a class="my-favorites" href="/profiles?filter=favorites">
                    <i class="fa fa-list"></i> My Favorites
                </a>              
              </li>
          <li>
            <a class="settings" href="/users/registration/edit">
              <i class="fa fa-sliders"></i> My Settings
            </a>          
          </li>
         </ul>
        </nav>
       </div>

      <div class="row wrapper border-bottom gray-bg page-heading">
        <h2><span class="num-players">14 Players - Tryouts One 2016</span</h2>
      </div>

  <div class="wrapper wrapper-content">
    <div class="row">
     <div class="col-lg-4 col-md-4 col-sm-6 col-xs-12">
      <div class="contact-box profile-24">
        <a href="/profiles/24">
          <div class="col-lg-offset-1 col-lg-4 col-xs-4">
             <div class="text-center">
                <img alt="image" src="profile-24.jpg" />
                  Age: 30
              </div>
          </div>
          <div class="col-lg-offset-1 col-lg-6 col-xs-8">
              <h3><strong>Jimmy Choos</strong></h3>
              <address>
                 <strong>St. George&#39;s College</strong><br>
                  Grade: <br>
                  Height: N/A<br>
                  Weight: N/A<br>
              </address>
          </div>
          <div class="clearfix"></div>
        </a>
      </div>
  </div>

这是触发游览的 JS:

<script type="text/javascript">
  $(document).on('turbolinks:load', function() {
    var tour = new Tour({
      storage: false,
      backdrop: true,
      steps: [
      {
        element: "div.navbar-header input#top-search",
        title: "Search",
        content: "Here you can search for players by their name, school, positions & bib color (that they wore in our tournament)"
      },
      {
        element: "div.page-heading h2 span.num-players",
        title: "Number of Players",
        content: "This is the number of players are in our database for this Tournament"
      },
      {
        element: '#page-wrapper div.contact-box.profile-<%= @profiles.first.id %>',
        title: "Player Info",
        content: "Here we have a quick snapshot of the player stats"
      }
    ]});

    // Initialize the tour
    tour.init();

    // Start the tour
    tour.start();
  });
</script>

以下是旅游在背景下的样子:

这是正确呈现的: 突出显示元素可见

这两个未正确呈现,突出显示的元素不可见: 突出显示的元素不可见 搜索栏元素不可见

如何让所有元素像顶部一样呈现,突出显示的元素可见?

编辑 1

这是一个显示行为的 JSFiddle:

https://jsfiddle.net/nrkry27p/

具体来说,请注意第二步,它不会像演示中的搜索那样突出显示。除了在我的真实代码中,搜索不会突出显示......但您应该能够了解正在发生的事情。

最终编辑

经过多轮编辑,不断的来来回回,我们终于弄明白了。因此,我决定清理所有对理解问题和解决方案并没有真正增加价值的编辑。

4

3 回答 3

1

目前该.tour-step-background元素有一个background-color:inherit属性,该属性继承transparentbody. 显示搜索元素的原因是它默认具有white来自浏览器的背景颜色。

尝试为.tour-step-background元素添加背景颜色,或者background-color为您的body元素设置 a。这应该“突出”它所在的步骤。

JSFIDDLE

.tour-step-background{
    background-color:#FFF;
}

编辑

这仍然是您遇到的问题z-indexbackground-color根据我们的讨论,事实证明,提供的 JS fiddle 不包括 bootstrap 中z-index关于navbar-fixed-top. 一旦确定了这一点,我们需要添加一些 JS 和一些 CSS 来解决问题。JS 在您开始巡回演出时将一个类应用于调用的主体is-touring,并在您结束时删除该类。

使用这个类,我们覆盖了 z-index 的值,navbar-static-top以便我们可以在游览显示上方显示其内部元素。onStart 和 onEnd 函数在引导程序的API 参考中可用。

CSS

/* ALSO REMOVE THE Z-INDEX VALUE ON THE RULE (line 247) */
.navbar-form-custom .form-contro{}
/* ADD THIS STYLE */
.is-touring .navbar-static-top{ 
    z-index:auto; 
}
/* BEGIN OPTIONAL CSS */
.tour-step-background {
  background-color:#fff;
  z-index: 2101;
}
.tour-step-backdrop{ /* this exists already, so update */
  z-index: 2102;
}
.tour-backdrop {
  z-index: 2100;
  opacity: .7;
}
.popover[class*=tour-] {
  z-index: 2101;
}
/* END OPTIONAL CSS */

JS

var tour = new Tour({
  storage: false,
  backdrop: true,
  onStart: function(){
    $('body').addClass('is-touring');
  },
  onEnd: function(){
    $('body').removeClass('is-touring');
  },
  steps: [
  {
    element: "div.navbar-header img.navbar-brand",
    title: "Go Home",
    content: "Go home to the main page."
  },
    {
    element: "div.navbar-header input#top-search",
    title: "Search",
    content: "Here you can search for players by their name, school, positions & bib color (that they wore in our tournament)"
  },
  {
    element: "span.num-players",
    title: "Number of Players",
    content: "This is the number of players that are in our database for this Tournament"
  },
  {
    element: '#page-wrapper div.contact-box.profile-24',
    title: "Player Info",
    content: "Here we have a quick snapshot of the player stats"
  }
]});

更新的小提琴

于 2016-12-08T00:53:56.337 回答
1

我已经玩过您的代码并找到了解决方案。问题是它为您的跨度添加了一个类,因此没有白色背景,您将不会获得突出显示行为。所以如果你在你的css中添加这个:

.num-players.tour-step-backdrop {
  background-color: white;
}

它会起作用的。最后一个也是:

.contact-box.profile-24.tour-step-backdrop {
  background-color: white;
}

或者你可以使用这样的一般规则:

.tour-step-backdrop {
    background-color: white;
}

更新:

根据您的屏幕截图和更改样式,我意识到您z-index的班级比backdrop本身低,因此仅更改背景无济于事:

.tour-step-backdrop {
    background-color: white;
    z-index: 3100;
}

更新 2:

该类是通用的,不应单独使用。我尝试了几种变体,这似乎有效:

.tour-step-backdrop.tour-tour-element {
   z-index: 4000;
   background-color: white;
 } 
于 2016-12-08T00:54:20.343 回答
1

您必须为要设置样式的元素提供初始背景值,因为即使在和元素上也没有默认background样式。解决这个问题很容易,只要给两者和它的父一个样式是. 只需将其附加如下。inheritspanh2span.num-playersh2background: inherit

h2 { 
  /* Other style */ 
  background: inherit; 
} 

.tour-step-backdrop { 
  /* Other style */ 
  background: inherit; 
}

编辑

JSFiddle

我评论z-index了,.tour-backdrop因为它覆盖了.tour-step-backdrop元素。

.tour-backdrop {
  /* z-index: 2100;  Disable this style. */
  opacity: .7;
}
于 2016-12-08T05:45:30.987 回答