Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在CSS中检查条件?_Javascript_Php_Jquery_Css_Masterslider - Fatal编程技术网

Javascript 如何在CSS中检查条件?

Javascript 如何在CSS中检查条件?,javascript,php,jquery,css,masterslider,Javascript,Php,Jquery,Css,Masterslider,使用主滑块时出现问题 它自动生成许多类 在我的例子中,我将视频和图片加载到幻灯片中 在我检查的代码中: <?php if($item->type == 1): ?> <!-- is Video --> <img class="ms-thumb video_slider" ... /> ?> <?php if($item->type == 2): ?> <!-- is Picture --> &l

使用主滑块时出现问题

它自动生成许多类

在我的例子中,我将视频和图片加载到幻灯片中

在我检查的代码中:

<?php if($item->type == 1): ?>   <!-- is Video -->
    <img class="ms-thumb video_slider" ... />
?>
<?php if($item->type == 2): ?>   <!-- is Picture -->
    <img class="ms-thumb picture_slider" ... />
    <div class="picturediv"></div> <!-- I tried to add manual element like that to assign instead of using: `ms-thumb-ol` but it auto remove when slide is generate -->
?>
我想在其中添加一个按钮播放代码:

div.ms-thumb-frame {
    position: relative;
}
div.ms-thumb-frame div.ms-thumb-ol {
    position: absolute;
    display: block;
    background: url(http://www.workbooks.com/sites/default/files/image/play-button-crm-homepage2.png);
    height: 55px;
    width: 57px;
    top: 0;
    left:0;
    right:0;
    bottom:0;
    margin:auto;
}
div.ms-thumb-frame div.ms-thumb-ol:hover {
    background: url(http://www.workbooks.com/sites/default/files/image/play-button-crm-homepage-11.png);
}
您可以看到,我只设置元素
ms thumb ol

此元素在另一个元素中相同


如果只有两种类型的项目,是否有任何方法签入
div.ms-thumb图片\u滑块
div.ms-thumb-ol
concurrent

,请使用如下三元运算符

$class= ($item->type == 1)?'ms-thumb video_slider':'ms-thumb picture_slider';
并在
img
标记中使用
$class
,如下所示

<img class="<?php echo $class;?>" ... />

如果只有两种类型的项…请使用如下三元运算符

$class= ($item->type == 1)?'ms-thumb video_slider':'ms-thumb picture_slider';
并在
img
标记中使用
$class
,如下所示

<img class="<?php echo $class;?>" ... />

如果只想编辑
ms-thumb-ol
,可以使用css同级组合器,因为它位于
div.ms-thumb-picture\u滑块的旁边。因此,要修改它,请为css添加以下选择器:

div.ms-thumb picture_slider + ms-thumb-ol{
//Whatever code you want that specific button to have but not the other button
}
+
组合器的作用是检查
div.ms-thumb picture\u滑块
类后面是否紧跟着
ms thumb ol
。如果是,则应用样式

编辑:

为使其更简单,请将代码从现有更改为:

div.ms-thumb-frame + div.ms-thumb-ol {
position: absolute;
display: block;
background: url(http://www.workbooks.com/sites/default/files/image/play-button-crm-homepage2.png);
height: 55px;
width: 57px;
top: 0;
left:0;
right:0;
bottom:0;
margin:auto;
}


div.ms-thumb-frame + div.ms-thumb-ol:hover {
background: url(http://www.workbooks.com/sites/default/files/image/play-    button-crm-homepage-11.png);
}
只要你的HTML是按照你在问题中显示的方式设置的,它就会工作


请注意,唯一的区别是同级组合器
+

如果只想编辑
ms thumb ol
,可以使用css同级组合器,因为它位于
div.ms-thumb picture\u滑块的旁边。因此,要修改它,请为css添加以下选择器:

div.ms-thumb picture_slider + ms-thumb-ol{
//Whatever code you want that specific button to have but not the other button
}
+
组合器的作用是检查
div.ms-thumb picture\u滑块
类后面是否紧跟着
ms thumb ol
。如果是,则应用样式

编辑:

为使其更简单,请将代码从现有更改为:

div.ms-thumb-frame + div.ms-thumb-ol {
position: absolute;
display: block;
background: url(http://www.workbooks.com/sites/default/files/image/play-button-crm-homepage2.png);
height: 55px;
width: 57px;
top: 0;
left:0;
right:0;
bottom:0;
margin:auto;
}


div.ms-thumb-frame + div.ms-thumb-ol:hover {
background: url(http://www.workbooks.com/sites/default/files/image/play-    button-crm-homepage-11.png);
}
只要你的HTML是按照你在问题中显示的方式设置的,它就会工作


请注意,唯一的区别是,如果您只想设置
div.ms-thumb-ol
的样式,则在
div.ms-thumb.picture\u滑块
内的元素
div.ms-thumb-frame
之后,您可以这样使用:

div.ms-thumb-frame div.ms-thumb.picture_slider + div.ms-thumb-ol {
    /* ... */
}

如果只想设置
div.ms-thumb-ol
的样式,则在
div.ms-thumb.picture\u滑块
元素内部
div.ms-thumb-frame
可以这样使用:

div.ms-thumb-frame div.ms-thumb.picture_slider + div.ms-thumb-ol {
    /* ... */
}

如果您想在css中应用条件,可以使用Sass。您的意思是使用JavaScript、css或PHP?“div.ms-thumb picture\u slider和div.ms-thumb-ol concurrent”您的意思是要检查..ol在..slider之后的时间?这可以通过CSS单独使用同级组合器来完成。检查我的答案。如果你想在css中应用条件,可以使用Sass。你是说使用JavaScript、css或PHP?“div.ms-thumb picture\u slider和div.ms-thumb-ol concurrent”您的意思是要检查..ol在..slider之后的时间?这可以通过CSS单独使用同级组合器来完成。检查我的答案。你的评论只会清除我的代码。这并不能解决我的问题。你的评论只会清除我的代码。这并不能解决我的问题。我使用的是运算符
+
,但我不知道只将样式应用于
ms thumb ol
。您可以使用css同级选择器
。你可以分享一个例子吗?谢谢。代码在我的答案@vanloc中。组合符*(不是选择器,将修复输入错误)是+号。按我在回答中的方式使用,它应该适合您(只要您的html与您在问题中的方式相同)。谢谢@Obed Marquez Parlapiano。我使用的是运算符
+
,但我不知道仅将样式应用于
ms thumb ol
。您可以使用css同级选择器
。你可以分享一个例子吗?谢谢。代码在我的答案@vanloc中。组合符*(不是选择器,将修复输入错误)是+号。在我的答案中使用它,它应该适合你(只要你的html和你在问题中使用的一样)。谢谢@Obed Marquez Parlapiano。