简体   繁体   English

如何在悬停模式弹出窗口上更改字体大小

[英]how to change font size on modal popup on hover

hey so i'm creating a button with modal display on hover so i managed to that part with the code below: 嘿,所以我要在悬停时创建一个带有模式显示的按钮,所以我使用下面的代码设法做到了这一点:

 <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('[data-toggle="popover"]').popover({ placement : 'top', trigger : 'hover' }); }); </script> 
 <a href="{{action('AltHr\\Chatbot\\ChatbotController@queries', [$companyID, $entityType, $entityValue])}}" class="btn btn-link" data-toggle="popover" title="{{ucwords($entityValue)}}" data-content="Default popover">{{ucwords($entityValue)}}</a> 

using this code i have achieved 使用我已经实现的这段代码 这个 so as you guys can see its working well but as you can see the title size is too huge, how can i make it smaller with css? 以便大家看到它的效果很好,但是看到标题太大时,如何使用CSS缩小它呢? also instead of showing the popup above, how can i show it on the right side? 还可以显示右侧,而不是显示上方的弹出窗口? im not really good in css. 我不是真的在CSS好。

If you are using Bootstrap for your popover, you'll need to use the javascript generated element class in your CSS in order to access the title for styling. 如果您将Bootstrap用于弹出窗口,则需要在CSS中使用javascript生成的元素类来访问样式标题。

Depending on the library version, it would be either .popover-title or .popover-header: 根据库的版本,它可能是.popover-title或.popover-header:

.popover-title {
    font-size: 15px;
}

For the placement issue, you'll make that change in your options when enabling the popover via Javascript: 对于放置问题,通过Javascript启用弹出框时,您将在选项中进行更改:

$('[data-toggle="popover"]').popover({
    placement : 'right',
    trigger : 'hover'
});

Update in response to comment below: A few potential solutions. 更新以回应以下评论:一些潜在的解决方案。

1) Make sure your CSS file is included after the file that includes the styles you need to override. 1)确保CSS文件包含在包含您需要覆盖的样式的文件之后。

2) Right-click and inspect element to see what existing style rule needs overriding. 2)右键单击并检查元素,以查看哪些现有样式规则需要覆盖。 If you need to get more specific to access the .popover-title, You may need to add the parent element to your CSS: 如果您需要更具体的方法来访问.popover-title,则可能需要将parent元素添加到CSS中:

.popover .popover-title {
    font-size: 15px;
}

3) (last resort?) Override with !important to ensure your styling takes priority: 3)(不得已吗?)用!important覆盖以确保您的样式优先:

.popover .popover-title {
    font-size: 15px !important;
}

To be able to make the font-size smaller it's probably easiest to add a font-size attribute in the css-class applied to the text (which you can find out by right-clicking -> inspect element in your browser). 为了能够减小字体大小,最简单的方法可能是在应用于文本的css类中添加一个font-size属性(您可以通过在浏览器中右键单击-> inspect元素来找出该属性)。

As to showing the popup to the right instead of above, simply change 至于显示弹出窗口的是右侧而不是上方,只需更改

placement: top

to

placement: right

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM