[英]CSS line-height property issue
I incorporated a Material-Floating Button to my web page and the functionality is working perfectly the way I want it to. 我将“材料浮动按钮”合并到我的网页中,并且该功能可以按我希望的方式完美运行。 The only issue I am having is the icons I have set up for them are not appear centered but, appears at the top of the button.
我唯一遇到的问题是我为它们设置的图标不是居中显示,而是显示在按钮顶部。 It appears that the css line-height is not working.
看来css行高不起作用。
Image of what appears on my webpage: Icon at top of Button 我的网页上显示的图像: Button顶部的图标
Link for Material-Floating Button: Material-Floating Button 物料浮动按钮的链接: 物料浮动按钮
Link for Demo of where the icon should be at: Demo 该图标应位于的演示链接: 演示
HTML Code: HTML代码:
<ul class="mfb-component--br mfb-zoomin" data-mfb-toggle="hover">
<li class="mfb-component__wrap">
<!-- the main menu button -->
<a href="#" class="mfb-component__button--main">
<!-- the main button icon visible by default -->
<i class="mfb-component__main-icon--resting ion-plus-round"></i>
<!-- the main button icon visible when the user is hovering/interacting with the menu -->
<i class="mfb-component__main-icon--active ion-close-round"></i>
</a>
<ul class="mfb-component__list">
<!-- a child button, repeat as many times as needed -->
<li>
<a href="#" data-mfb-label="Edit This Action" class="mfb-component__button--child">
<i class="mfb-component__child-icon ion-edit"></i>
</a>
</li>
</ul>
</li>
</ul>
Part of CSS Code: CSS代码的一部分:
.mfb-component__button--main, .mfb-component__button--child {
background-color: #E40A5D;
display: inline-block;
position: relative;
border: none;
border-radius: 50%;
box-shadow: 0 0 4px rgba(0, 0, 0, 0.14), 0 4px 8px rgba(0, 0, 0, 0.28);
cursor: pointer;
outline: none;
padding: 0;
position: relative;
-webkit-user-drag: none;
color: #f1f1f1; }
/**
* This is the unordered list for the list items that contain
* the child buttons.
*
*/
.mfb-component__list {
list-style: none;
margin: 0;
padding: 0; }
.mfb-component__list > li {
display: block;
position: absolute;
top: 0;
right: 1px;
padding: 10px 0;
margin: -10px 0; }
/**
* These are the basic styles for all the icons inside the main button
*/
.mfb-component__icon, .mfb-component__main-icon--active,
.mfb-component__main-icon--resting, .mfb-component__child-icon {
position: absolute;
font-size: 18px;
text-align: center;
line-height: 56px;
width: 100%; }
.mfb-component__wrap {
padding: 25px;
margin: -25px; }
I think you're right about the line-height. 我认为您对行高是正确的。 Is there another css rule somewhere over-riding it?
是否有其他的CSS规则取代它? Try adding and important to target it a bit better.
尝试添加和重要一点,以更好地定位它。
line-height: 56px !important;
If that doesn't work add some parent elements before you're css rule like #menu and .mfb-component__wrap 如果这样不起作用,请在使用css规则之前添加一些父元素,例如#menu和.mfb-component__wrap
#menu .mfb-component__wrap i.mfb-component__main-icon--active.ion-close-round{
position: absolute;
font-size: 18px;
text-align: center;
line-height: 56px;
width: 100%; }
If neither of the above work just use 'top' as a workaround instead. 如果上述两种方法均无效,则可以使用“ top”作为替代方法。
#menu .mfb-component__wrap i.mfb-component__main-icon--active.ion-close-round{
position: absolute;
font-size: 18px;
text-align: center;
line-height: 0px;
width: 100%;
top: 17px; }
Hope that sorts it for you! 希望能为您排序!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.