【发布时间】:2018-12-04 09:43:27
【问题描述】:
我正在使用引导程序和高级自定义字段,并且有一个可以输出图像和文本的中继器字段。我试图让图像和文本每隔一个循环的行交换边(向左或向右浮动)
以下 CSS 是最合乎逻辑的,但我尝试了许多不同的嵌套和变体。
.tour-row .col-md-5:nth-child(odd) {
float: left !important;
}
.tour-row .col-md-5:nth-child(even) {
float: right !important;
}
<div class="wrapper clear">
<div class="row tour-row">
<h2 class="tour-title">
Tour 2
</h2>
<div class="tour-button btn btn-primary blk-button xola-checkout xola-custom" data-button-id="asdfddddddd">BOOK NOW</div>
<div class="col-md-5">
<div class="slideshow-tours">
<div class="tour-slideshow">
<img src="http://handlebardev.mscdev/wp-content/uploads/2018/06/best-funny-dog-breed-mixes-high-resolution-wallpaper-funnypicture-org-pics-of-and-breeding-style.jpg">
</div>
<div class="tour-slideshow">
<img src="http://handlebardev.mscdev/wp-content/uploads/2018/06/dogs-high-resolution-wallpaper-4.jpg">
</div>
<div class="tour-slideshow">
<img src="http://handlebardev.mscdev/wp-content/uploads/2018/06/best-funny-dog-breed-mixes-high-resolution-wallpaper-funnypicture-org-pics-of-and-breeding-style.jpg">
</div>
<div class="tour-slideshow">
<img src="http://handlebardev.mscdev/wp-content/uploads/2018/06/dogs-high-resolution-wallpaper-4.jpg">
</div>
</div>
</div>
<div class="col-md-7">
<p>is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
</div>
<!--end row -->
</div>
<!-- end wrapper -->
<div class="wrapper clear">
<div class="row tour-row">
<h2 class="tour-title">
another tour
</h2>
<div class="tour-button btn btn-primary blk-button xola-checkout xola-custom" data-button-id="klasdjfd">BOOK NOW</div>
<div class="col-md-5">
<div class="slideshow-tours">
<div class="tour-slideshow">
<img src="http://handlebardev.mscdev/wp-content/uploads/2018/06/1springmural_handlebar.jpg">
</div>
<div class="tour-slideshow">
<img src="http://handlebardev.mscdev/wp-content/uploads/2018/06/dogs-high-resolution-wallpaper-4.jpg">
</div>
</div>
</div>
<div class="col-md-7">
<p>is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
</div>
<!--end row -->
</div>
<!-- end wrapper -->
</div>
<!-- end wrapper -->
【问题讨论】:
-
请将您拥有的 PHP 代码替换为浏览器看到的生成的 HTML。
-
@TylerH 我替换了。
-
喜欢这个jsfiddle.net/bu93m26p ?
-
nth-child 不是这样工作的。它有父关系。尝试添加另一个 col-md-5 作为同级并检查自己。
-
你应该在父元素上定位第n个子元素,然后下降jsfiddle.net/bu93m26p/9
标签: html css css-selectors repeater advanced-custom-fields