我使用CSS nth類型(偶數)排序div。通常它工作正常,但是當我發出AJAX請求並將新的HTML div放到另一個之後時,選擇器開始工作很奇怪。CSS奇怪的行爲類型的nth
.row > .cd-timeline-block-sort:nth-of-type(even) > .cd-timeline-content {
float: right;
}
<div class="cd-timeline-block cd-timeline-block-sort" data-event-id="284">
<div class="cd-timeline-block cd-timeline-block-sort" data-event-id="268">
<div class="cd-timeline-block cd-timeline-block-sort" data-event-id="282">
和後AJAX請求:
<!-- 1 --><div class="cd-timeline-block cd-timeline-block-sort" data-event-id="284">
<!-- 2 --><div class="cd-timeline-block" data-event-id="268" style="display: none;">
<!-- 3 --><div class="cd-timeline-block cd-timeline-block-sort eventForm" id="eventEditForm" style="display: block;">
<!-- 4 --><div class="cd-timeline-block cd-timeline-block-sort" data-event-id="282">
以我第二個例子是4個格,並將它們的3類.CD-timeline-塊排序。我需要把(1)放在左邊,(3)放在右邊,(4)放在左邊。
你能發佈相關的html嗎? –
好吧,我更新了帖子 –