首页 \ 问答 \ 我的网站上的jQuery Nivo Slider有什么用?(What is up with jQuery Nivo Slider on my site?)

我的网站上的jQuery Nivo Slider有什么用?(What is up with jQuery Nivo Slider on my site?)

我安装了在我的网站上使用jQuery的Nivo Slider(http://nivo.dev7studios.com/),这是一个Magento电子商务网站。

我的网站是http://bikeshop.gostorego.com/

任何想法为什么在主页上可以看到滑块的位置,但加载图标仅存在不显示幻灯片?

谢谢


I have installed the Nivo Slider (http://nivo.dev7studios.com/) that uses jQuery on my site which is a Magento ecommerce site.

My site is http://bikeshop.gostorego.com/

Any ideas why on the homepage you can see where the slider goes, but the loading icon is only present not showing the slides?

Thanks


原文:https://stackoverflow.com/questions/6208910
更新时间:2021-10-29 16:10

最满意答案

沿着主轴对齐Flex项目的方法

正如问题所述:

沿着主轴对齐flex项目有一个属性: justify-content

要沿着交叉轴对齐Flex项目,有三个属性: align-contentalign-itemsalign-self

问题然后问:

为什么没有justify-itemsjustify-self属性?

一个答案可能是: 因为没有必要。

Flexbox规范提供了两种沿着主轴对齐柔性物品的方法:

  1. justify-content关键字属性,和
  2. auto边距

证明内容

justify-content属性将Flex项目沿着Flex容器的主轴对齐。

它应用于Flex容器,但仅影响Flex项目。

有五个对齐选项:

  • flex-start start〜Flex项目被打包到该行的开头。

    在此输入图像说明

  • flex-end end〜Flex项目被打包到行尾。

    在此输入图像说明

  • center 〜Flex物品朝向线的中心。

    在此输入图像说明

  • space-between 〜Flex物品间隔均匀,第一个物品与容器的一个边缘对齐,最后一个物品与相对边缘对齐。 第一个和最后一个项目使用的边缘取决于flex-direction和写入模式 ( ltrrtl )。

    在此输入图像说明

  • space-aroundspace-between相同,但两端的半角空格不同。

    在此输入图像说明


汽车保证金

使用auto边距 ,柔性物品可以居中,间隔或包装成子组。

不同于适用于flex容器的justify-contentauto边距继续进行flex项目。


将一组弹性项目对齐到右边,但第一个项目在左边

问题的场景:

  • 使一组flex项目对齐( justify-content: flex-end ),但是第一个对齐左对齐( justify-self: flex-start

    考虑一个带有一组导航项目和徽标的标题部分。 通过justify-self ,标识可以左对齐,而导航项目保持最右边,整个事物可以平滑调整(“flexes”)到不同的屏幕尺寸。

在此输入图像说明

在此输入图像说明


其他有用的场景:

在此输入图像说明

在此输入图像说明

在此输入图像说明


将flex项目放在角落里

问题的场景:

  • 将flex项目放在角落里.box { align-self: flex-end; justify-self: flex-end; } .box { align-self: flex-end; justify-self: flex-end; }

在此输入图像说明


垂直和水平放置柔性物品

在此输入图像说明

margin: autojustify-content: center的替代方案justify-content: centeralign-items: center

而不是Flex容器上的这个代码:

.container {
    justify-content: center;
    align-items: center;
}

您可以在flex项目上使用它:

.box56 {
    margin: auto;
}

定位溢出容器的flex项目时,此选项很有用。


中心一个flex项目,并在第一个和第一个边缘之间居中第二个flex项目

Flex容器通过分配可用空间来对齐弹性项目。

因此,为了创造平等的平衡 ,中间物品可以集中在容器中,同时还有一个物品,必须引入平衡物。

在下面的例子中,引入了不可见的第三个弹性项目(框61和68)来平衡“实际”项目(框63和66)。

在此输入图像说明

在此输入图像说明

当然,这种方法在语义上是没有什么大的。

或者,您可以使用伪元素而不是实际的DOM元素。 或者您可以使用绝对定位。 所有三种方法都在这里: 中心和底部对齐的柔性物品

注意:上面的例子只有在最外面的物品是相同的高度/宽度的情况下,才能以真实居中的方式工作。 当flex项目长度不同时,请参见下一个示例。


当相邻项目大小不同时,中心一个弹性项目

问题的场景:

  • 在一行三个flex项目中,将中间项目粘贴到容器的中心( justify-content: center )并将相邻项目对齐到容器边缘( justify-self: flex-startjustify-self: flex-end )。

    请注意,如果相邻项目具有不同的宽度,则justify-content属性上的space-aroundspace-between值将不会使中间项目与容器相关。

如上所述,除非所有柔性物品的宽度或高度相同(取决于flex-direction ),否则中间物品不能真正居中。 这个问题使得一个justify-self属性(设计来处理任务当然)的强大的例子。

#container {
  display: flex;
  justify-content: space-between;
  background-color: lightyellow;
}
.box {
  height: 50px;
  width: 75px;
  background-color: springgreen;
}
.box1 {
  width: 100px;
}
.box3 {
  width: 200px;
}
#center {
  text-align: center;
  margin-bottom: 5px;
}
#center > span {
  background-color: aqua;
  padding: 2px;
}
<div id="center">
  <span>TRUE CENTER</span>
</div>

<div id="container">
  <div class="box box1"></div>
  <div class="box box2"></div>
  <div class="box box3"></div>
</div>

<p>The middle box will be truly centered only if adjacent boxes are equal width.</p>

以下是解决这个问题的两种方法:

解决方案#1:绝对定位

flexbox规格允许对Flex项目进行绝对定位 。 这允许中间物品完美地居中,而不管其兄弟姐妹的大小如何。

请记住,像所有绝对定位的元素一样,这些项目将从文档流程中删除。 这意味着它们不占用容器中的空间,并且可以与其兄弟姐妹重叠。

在下面的示例中,中间项目以绝对定位为中心,外部项目保持流入。 但是可以以相反的方式实现相同的布局:使用justify-content: center中心中间的项目justify-content: center并绝对定位外部项目。

在此输入图像说明

解决方案#2:嵌套Flex容器(无绝对定位)

.container {
  display: flex;
}
.box {
  flex: 1;
  display: flex;
  justify-content: center;
}
.box71 > span { margin-right: auto; }
.box73 > span { margin-left: auto;  }

/* non-essential */
.box {
  align-items: center;
  border: 1px solid #ccc;
  background-color: lightgreen;
  height: 40px;
}
<div class="container">
  <div class="box box71"><span>71 short</span></div>
  <div class="box box72"><span>72 centered</span></div>
  <div class="box box73"><span>73 loooooooooooooooong</span></div>
</div>

以下是它的工作原理:

  • 顶级div( .container )是一个flex容器。
  • 每个小孩div( .box )现在都是一个flex项目。
  • 每个.box项目都被赋予了flex: 1 ,以便平均分配容器空间。
  • 现在这些项目正在占用行中的所有空间,并且宽度相等。
  • 使每个项目成为(嵌套)的Flex容器并添加justify-content: center
  • 现在每个span元素都是一个居中的flex项目。
  • 使用柔性auto边距可以左右移动外span

您也可以放弃justify-content并专门使用auto边距。

但是justify-content可以在这里工作,因为auto边距总是优先。 从规格:

8.1。 auto边距对齐

在通过justify-contentalign-self方式对齐之前,任何正的可用空间都会分配到该维度中的自动边距。


对齐内容:空格相同(概念)

回过头来justify-content一分钟,这是一个想法再一个选择。

  • space-samespace-betweenspace-around混合。 Flex项目均匀间隔(如space-between ),除了两端的空格(如space-around )之外,两端都有全尺寸的空格。

这个布局可以通过::before::after伪元素在flex容器上实现。

在此输入图像说明

(信用:代码的@oriol ,标签的@crl )

更新:浏览器已经开始实现space-evenly ,这实现了上述。 有关详细信息,请参阅此信息: 柔性物品周围的等间距


PLAYGROUND (包括上面所有示例的代码)


Methods for Aligning Flex Items along the Main Axis

As stated in the question:

To align flex items along the main axis there is one property: justify-content

To align flex items along the cross axis there are three properties: align-content, align-items and align-self.

The question then asks:

Why are there no justify-items and justify-self properties?

One answer may be: Because they're not necessary.

The flexbox specification provides two methods for aligning flex items along the main axis:

  1. The justify-content keyword property, and
  2. auto margins

justify-content

The justify-content property aligns flex items along the main axis of the flex container.

It is applied to the flex container but only affects flex items.

There are five alignment options:

  • flex-start ~ Flex items are packed toward the start of the line.

    enter image description here

  • flex-end ~ Flex items are packed toward the end of the line.

    enter image description here

  • center ~ Flex items are packed toward the center of the line.

    enter image description here

  • space-between ~ Flex items are evenly spaced, with the first item aligned to one edge of the container and the last item aligned to the opposite edge. The edges used by the first and last items depends on flex-direction and writing mode (ltr or rtl).

    enter image description here

  • space-around ~ Same as space-between except with half-size spaces on both ends.

    enter image description here


Auto Margins

With auto margins, flex items can be centered, spaced away or packed into sub-groups.

Unlike justify-content, which is applied to the flex container, auto margins go on flex items.

They work by consuming all free space in the specified direction.


Align group of flex items to the right, but first item to the left

Scenario from the question:

  • making a group of flex items align-right (justify-content: flex-end) but have the first item align left (justify-self: flex-start)

    Consider a header section with a group of nav items and a logo. With justify-self the logo could be aligned left while the nav items stay far right, and the whole thing adjusts smoothly ("flexes") to different screen sizes.

enter image description here

enter image description here


Other useful scenarios:

enter image description here

enter image description here

enter image description here


Place a flex item in the corner

Scenario from the question:

  • placing a flex item in a corner .box { align-self: flex-end; justify-self: flex-end; }

enter image description here


Center a flex item vertically and horizontally

enter image description here

margin: auto is an alternative to justify-content: center and align-items: center.

Instead of this code on the flex container:

.container {
    justify-content: center;
    align-items: center;
}

You can use this on the flex item:

.box56 {
    margin: auto;
}

This alternative is useful when centering a flex item that overflows the container.


Center a flex item, and center a second flex item between the first and the edge

A flex container aligns flex items by distributing free space.

Hence, in order to create equal balance, so that a middle item can be centered in the container with a single item alongside, a counterbalance must be introduced.

In the examples below, invisible third flex items (boxes 61 & 68) are introduced to balance out the "real" items (box 63 & 66).

enter image description here

enter image description here

Of course, this method is nothing great in terms of semantics.

Alternatively, you can use a pseudo-element instead of an actual DOM element. Or you can use absolute positioning. All three methods are covered here: Center and bottom-align flex items

NOTE: The examples above will only work – in terms of true centering – when the outermost items are equal height/width. When flex items are different lengths, see next example.


Center a flex item when adjacent items vary in size

Scenario from the question:

  • in a row of three flex items, affix the middle item to the center of the container (justify-content: center) and align the adjacent items to the container edges (justify-self: flex-start and justify-self: flex-end).

    Note that values space-around and space-between on justify-content property will not keep the middle item centered in relation to the container if the adjacent items have different widths (see demo).

As noted, unless all flex items are of equal width or height (depending on flex-direction), the middle item cannot be truly centered. This problem makes a strong case for a justify-self property (designed to handle the task, of course).

#container {
  display: flex;
  justify-content: space-between;
  background-color: lightyellow;
}
.box {
  height: 50px;
  width: 75px;
  background-color: springgreen;
}
.box1 {
  width: 100px;
}
.box3 {
  width: 200px;
}
#center {
  text-align: center;
  margin-bottom: 5px;
}
#center > span {
  background-color: aqua;
  padding: 2px;
}
<div id="center">
  <span>TRUE CENTER</span>
</div>

<div id="container">
  <div class="box box1"></div>
  <div class="box box2"></div>
  <div class="box box3"></div>
</div>

<p>The middle box will be truly centered only if adjacent boxes are equal width.</p>

Here are two methods for solving this problem:

Solution #1: Absolute Positioning

The flexbox spec allows for absolute positioning of flex items. This allows for the middle item to be perfectly centered regardless of the size of its siblings.

Just keep in mind that, like all absolutely positioned elements, the items are removed from the document flow. This means they don't take up space in the container and can overlap their siblings.

In the examples below, the middle item is centered with absolute positioning and the outer items remain in-flow. But the same layout can be achieved in reverse fashion: Center the middle item with justify-content: center and absolutely position the outer items.

enter image description here

Solution #2: Nested Flex Containers (no absolute positioning)

.container {
  display: flex;
}
.box {
  flex: 1;
  display: flex;
  justify-content: center;
}
.box71 > span { margin-right: auto; }
.box73 > span { margin-left: auto;  }

/* non-essential */
.box {
  align-items: center;
  border: 1px solid #ccc;
  background-color: lightgreen;
  height: 40px;
}
<div class="container">
  <div class="box box71"><span>71 short</span></div>
  <div class="box box72"><span>72 centered</span></div>
  <div class="box box73"><span>73 loooooooooooooooong</span></div>
</div>

Here's how it works:

  • The top-level div (.container) is a flex container.
  • Each child div (.box) is now a flex item.
  • Each .box item is given flex: 1 in order to distribute container space equally.
  • Now the items are consuming all space in the row and are equal width.
  • Make each item a (nested) flex container and add justify-content: center.
  • Now each span element is a centered flex item.
  • Use flex auto margins to shift the outer spans left and right.

You could also forgo justify-content and use auto margins exclusively.

But justify-content can work here because auto margins always have priority. From the spec:

8.1. Aligning with auto margins

Prior to alignment via justify-content and align-self, any positive free space is distributed to auto margins in that dimension.


justify-content: space-same (concept)

Going back to justify-content for a minute, here's an idea for one more option.

  • space-same ~ A hybrid of space-between and space-around. Flex items are evenly spaced (like space-between), except instead of half-size spaces on both ends (like space-around), there are full-size spaces on both ends.

This layout can be achieved with ::before and ::after pseudo-elements on the flex container.

enter image description here

(credit: @oriol for the code, and @crl for the label)

UPDATE: Browsers have begun implementing space-evenly, which accomplishes the above. See this post for details: Equal space between flex items


PLAYGROUND (includes code for all examples above)

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。