html - 为特定的(不是所有的)popover 容器设置最大宽度和 css 颜色(help icon1)

标签 html css css-selectors bootstrap-popover

我想知道如何将 CSS 选择器应用于特定容器。

我尝试将以下 CSS 更改应用于帮助图标 1 而不是帮助图标 2。

我想应用于 helpicon1 弹出窗口的 CSS 更改是:- h6 红色并将 Popover Container 的最大宽度设置为 385px

http://jsfiddle.net/E5Ly5/683/

$('.ico').popover({
    placement: 'bottom',
    container: 'body',
    html: true,
    content: function () {
        return $(this).next('.popper-content').html();
    }
});

$('.icon2').popover({
    placement: 'bottom',
    container: 'body',
    html: true,
    content: function () {
        return $(this).next('.popper-content').html();
    }
});
body {
    padding: 50px;
}
.popover-title {
    color: blue;
    font-size: 15px;
}
.popover-content{
  max-width:385px;
}
  div.test div.hide h6{
    color: red;
    font-size: 10px;
} 
 <div class="test"> 
               <i class="fa fa-question-circle ico" 
               data-toggle="popover"  data-placement="right" 
               data-trigger="hover" >help icon1</i>
               
<div class="popper-content hide"><h6>
Red color Title. </h6>
  <ul>
    <li>Popover container apply max -width: 385px</li>
    <li> test1.</li>
  </ul>
</div></div>      

<div class="test"> 
               <i class="fa fa-question-circle icon2" 
               data-toggle="popover"  data-placement="right" 
               data-trigger="hover" >help icon2</i>
               
<div class="popper-content hide"><h6>
Black color title </h6>
  <ul>
    <li>Popover Container no specific width.</li>
    <li>Test2.</li> </ul>
</div></div>      
      

最佳答案

您尝试做的事情无法通过您加载内容的方式来完成。 bootstrap popover 元素在无法定位的 DOM 的不同部分呈现 popper-content。

为什么不直接将包含 color:red 的类直接附加到您想要的 h6 上呢?

这是一个 fiddle : http://jsfiddle.net/E5Ly5/684/

关于html - 为特定的(不是所有的)popover 容器设置最大宽度和 css 颜色(help icon1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41252675/

相关文章:

html - 如何使用 CSS 选择文本节点

html - 悬停在 div 上不起作用

javascript - 通过 Javascript 从点击事件中获取文本偏移量?

html - Bootstrap 3 div 自动宽度不是父 div 的 100%

html - 使绝对元素成为其父元素的父元素的宽度

html - :first-child and :last-child applies to all elements

php - fputcsv 将 HTML 代码插入到 csv 文件中

javascript - 单击按钮时下载文件 jQuery

javascript - jQuery 显示和隐藏切换

css - 我可以在 CSS 语句中定位一个类吗?