带有 <a> 标签的 Jssor 旋转木马滑块在 safari 中不起作用

Jssor carousel slider with <a> tag not working in safari

这是我的代码:

<style>
div.img {
    margin: 5px;
    padding: 0px;
    height: auto;
    width: auto;
    float: left;
}

    div.img span.img {
        display: inline-block;
    }

a.img:hover img {
}

    .jssorb03 {
    position: absolute;
}

    .jssorb03 div, .jssorb03 div:hover, .jssorb03 .av {
        position: absolute;
        /* size of bullet elment */
        width: 21px;
        height: 21px;
        text-align: center;
        line-height: 21px;
        color: white;
        font-size: 12px;
        background: url(../img/b03.png) no-repeat;
        overflow: hidden;
        cursor: pointer;
    }

    .jssorb03 div {
        background-position: -5px -4px;
    }

        .jssorb03 div:hover, .jssorb03 .av:hover {
            background-position: -35px -4px;
        }

    .jssorb03 .av {
        background-position: -65px -4px;
    }

    .jssorb03 .dn, .jssorb03 .dn:hover {
        background-position: -95px -4px;
    }

<div class="gallery-page" style="margin: 75px auto; text-align: center;">
<div id="slider1_container" class="hidden-xs" style="position: relative; top: 0px; width: 800px; height: 300px; overflow: hidden;text-align:center;">
    <div u="slides" style="cursor: move; position: absolute; top: 0px; width: 780px; height: 300px; overflow: hidden;">

        @foreach (var item in fa.get_albums())
        {

            url = "~/content/images/" + item.picture;

            if (@item.Show.Equals(true))
            {
        <div class="hidden-xs" style="width:250px;display: inline-block;margin-right:25px;">
            <a href="/Home/show_album/@item.id" class="img">
                <div class="img opct-jq" style="opacity: 0.75; filter: alpha(opacity=75);display:flex;background-image:url('@Url.Content(url)');background-position;background-repeat: no-repeat;background-position: left top;background-size: 100%;width:250px;height:250px;">  </div>
            </a>
            <p style="width:100%;color:#105c59;text-align:center;font-size:16px;font-weight:100;font-family:'Malgun Gothic'">@Html.DisplayFor(modelItem => item.name)</p>

        </div>
            }


        }
    </div>


    <!-- Arrow Left -->
    <span u="arrowleft" class="jssora03l hidden-xs" style="top: 110px; left: -1px; background-image: url('../../../Content/slider arrow left.png');">
    </span>
    <!-- Arrow Right -->
    <span u="arrowright" class="jssora03r hidden-xs" style="top: 110px; right: -11px; background-image: url('../../../Content/slider arrow right.png');">
    </span>

</div>

这是我的 Jssor 设置脚本

<script>
jQuery(document).ready(function ($) {
    var options = {
        $AutoPlay: true,                                    //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false
        $AutoPlaySteps: 1,                                  //[Optional] Steps to go for each navigation request (this options applys only when slideshow disabled), the default value is 1
        $AutoPlayInterval: 4000,                            //[Optional] Interval (in milliseconds) to go for next slide since the previous stopped if the slider is auto playing, default value is 3000
        $PauseOnHover: 3,                               //[Optional] Whether to pause when mouse over if a slider is auto playing, 0 no pause, 1 pause for desktop, 2 pause for touch device, 3 pause for desktop and touch device, 4 freeze for desktop, 8 freeze for touch device, 12 freeze for desktop and touch device, default value is 1

        $ArrowKeyNavigation: true,                          //[Optional] Allows keyboard (arrow key) navigation or not, default value is false
        $SlideDuration: 950,                                //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 500
        $MinDragOffsetToSlide: 50,                          //[Optional] Minimum drag offset to trigger slide , default value is 20
        $SlideWidth: 250,                                   //[Optional] Width of every slide in pixels, default value is width of 'slides' container
        //$SlideHeight: 150,                                //[Optional] Height of every slide in pixels, default value is height of 'slides' container
        $SlideSpacing: 15,                                  //[Optional] Space between each slide in pixels, default value is 0
        $DisplayPieces: 3,                                  //[Optional] Number of pieces to display (the slideshow would be disabled if the value is set to greater than 1), the default value is 1
        $ParkingPosition: 0,                              //[Optional] The offset position to park slide (this options applys only when slideshow disabled), default value is 0.
        $UISearchMode: 1,                                   //[Optional] The way (0 parellel, 1 recursive, default value is 1) to search UI components (slides container, loading screen, navigator container, arrow navigator container, thumbnail navigator container etc).
        $PlayOrientation: 1,                                //[Optional] Orientation to play slide (for auto play, navigation), 1 horizental, 2 vertical, 5 horizental reverse, 6 vertical reverse, default value is 1
        $DragOrientation: 1,                                //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 either, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $DisplayPieces is greater than 1, or parking position is not 0)

        $BulletNavigatorOptions: {                                //[Optional] Options to specify and enable navigator or not
            $Class: $JssorBulletNavigator$,                       //[Required] Class to create navigator instance
            $ChanceToShow: 0,                               //[Required] 0 Never, 1 Mouse Over, 2 Always
            $AutoCenter: 0,                                 //[Optional] Auto center navigator in parent container, 0 None, 1 Horizontal, 2 Vertical, 3 Both, default value is 0
            $Steps: 1,                                      //[Optional] Steps to go for each navigation request, default value is 1
            $Lanes: 1,                                      //[Optional] Specify lanes to arrange items, default value is 1
            $SpacingX: 0,                                   //[Optional] Horizontal space between each item in pixel, default value is 0
            $SpacingY: 0,                                   //[Optional] Vertical space between each item in pixel, default value is 0
            $Orientation: 1                                 //[Optional] The orientation of the navigator, 1 horizontal, 2 vertical, default value is 1
        },

        $ArrowNavigatorOptions: {
            $Class: $JssorArrowNavigator$,              //[Requried] Class to create arrow navigator instance
            $ChanceToShow: 2,                               //[Required] 0 Never, 1 Mouse Over, 2 Always
            $AutoCenter: 0,                                 //[Optional] Auto center navigator in parent container, 0 None, 1 Horizontal, 2 Vertical, 3 Both, default value is 0
            $Steps: 1                                      //[Optional] Steps to go for each navigation request, default value is 1
        }
    };

    var jssor_slider1 = new $JssorSlider$("slider1_container", options);

在所有浏览器中,我都可以重定向到由 foreach 创建的标签的 url,但在 Safari 中什么也不会发生。

如有任何帮助,我们将不胜感激。

尝试将 display:block 样式添加到 href。

  <div>
      <a u="image" href="www.example.com" style="display:block">
          <img src="/example.png" />
      </a>
  </div>

我通过将 <p> 标签放在 <a class="img"> 中解决了这个问题。

当我将 <a><p> 放在父 <Div>

中彼此靠近时,safari 变得疯狂

所以我改变这个:

<div class="hidden-xs" style="width:250px;display: inline-block;margin-right:25px;">
        <a href="/Home/show_album/@item.id" class="img">
            <div class="img opct-jq" style="opacity: 0.75; filter: alpha(opacity=75);display:flex;background-image:url('@Url.Content(url)');background-position;background-repeat: no-repeat;background-position: left top;background-size: 100%;width:250px;height:250px;">  </div>
        </a>
        <p style="width:100%;color:#105c59;text-align:center;font-size:16px;font-weight:100;font-family:'Malgun Gothic'">@Html.DisplayFor(modelItem => item.name)</p>

    </div>

对此:

<div class="hidden-xs" style="width:250px;display: inline-block;margin-right:25px;">
        <a href="/Home/show_album/@item.id" class="img">
            <div class="img opct-jq" style="opacity: 0.75; filter: alpha(opacity=75);display:flex;background-image:url('@Url.Content(url)');background-position;background-repeat: no-repeat;background-position: left top;background-size: 100%;width:250px;height:250px;">  </div>
        <p style="width:100%;color:#105c59;text-align:center;font-size:16px;font-weight:100;font-family:'Malgun Gothic'">@Html.DisplayFor(modelItem => item.name)</p>

        </a>

    </div>

希望它能帮助到其他人