In IE11 using pseudo element ::before and display:table-cell and glyphicons contens wont show up

主宰稳场 提交于 2019-12-18 08:56:32

问题


I've spent a rather good time on this now but cant come to a solution. My problem is that I want to display a glyphicon before the content of a text-block and that element with the icon has should fill up all the height that the body needs. This works in all browser versions except IE. I have boiled it down in this fiddle

<div class="block">
  <div class="body">BODY</div>
</div>

.body::before {
    background: blue;
    content: "\e005";
    font-family: "Glyphicons Halflings";
    display: table-cell;
    width:30%;
}

.body {
    background-color: green;
    display: table;
    width: 25%;
}

If you add/remove the display: table-cell on the fiddle above using IE11 you will see where my problem is. Can someone give me a solution to this, or even better, explain what is happening.


回答1:


There is an active bug report about this issue in Microsoft Connect website. On IE, font-family decleration is ignored in pseudo-element with display: table-cell; property.

To workaround this problem, you need to set display: inline-block;.




回答2:


Adding float:left to .body does the trick

.body:before {
    background: blue;
    content: "\e005";
    font-family: "Glyphicons Halflings";
    display: table-cell;
    width:30%;
    float:left;
}

fiddle


I will keep this previous answer here. Users may find it useful:

You can try using content: "\2665" instead of "/e005"

.body:before {
    background: blue;
    content: "\2665";
    display: table-cell;
    width:30%;
}

fiddle

Click here for more info.



来源:https://stackoverflow.com/questions/29379602/in-ie11-using-pseudo-element-before-and-displaytable-cell-and-glyphicons-cont

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