Why can't I decrease the line-height of this text?

一个人想着一个人 提交于 2019-12-03 09:19:00
Ibu

Because the em tag is inline and its line-height cannot be lower than its parent div.

For example, if you set the line-height of the parent to 10px, then you would be able to decrease the line-height of em tag to 10px as well.

In order for line-height property to work, div should has display property equal to block

.app-button-label{
    line-height: 20px;
    display: block;
 }
Grace

I was facing this problem with divs in mobile view - the line height was way too big and line-height wasn't working! I managed to make it work by adding "display:block", per advice here: Why isn't the CSS property 'line-height' letting me make tight line-spaces in Chrome?

Hope this helps anyone else facing the same problem in future

You seem to be using normalized css option in jsfiddle - which equates to the CSS rules being reset - ala http://meyerweb.com/eric/tools/css/reset/

You can either reset the reset, or use a different reset if you really need it.

See here for more details:

http://sixrevisions.com/css/a-comprehensive-guide-to-css-resets/

The best way to do it is using css reset.

Write your own or use popular one like

http://meyerweb.com/eric/tools/css/reset/

The simplest way is to specify the line height with a higher priority, for example you could write: line-height: 14px !important;

If it is still not working set high priority in both where you u would like to decrease the line height (inline css) and also put in the body css .. remember the high priority (!important;) because it overrides any other unknown css rules.

Hope this helps

Ahmed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!