【发布时间】:2018-07-20 21:04:37
【问题描述】:
我正在尝试在如下所示的范围内显示一条消息
<span class="glyphicon glyphicon-exclamation-sign alert alert-danger" id="ErrorMessage" style="display: none;" aria-hidden="true"></span>`
默认情况下,此跨度没有文本,但会根据发生的错误填充错误文本。
问题是文本在元素内显得拉伸并且看起来很糟糕。我不确定用什么方法来解决这个问题。任何意见,将不胜感激。
编辑:仅当我添加“glyphicon”类时才会出现问题。
我正在使用 JS 填充,例如:
var msg = document.getElementById("ErrorMessage");
msg.innerHTML = "There has been an error";`
这里没有涉及到自定义 CSS 样式。
<div role="main">
<span id="maincontent"/>
<div class="container">
<div class="jumbotron">
<div style="height: 50px; float: center;">
<h3>List Herd Numbers in Commonage</h3>
</div>
<form role="form" id="HerdForm">
<div class="form-inline">
<label class="control-label" for="commonage_id">Enter Commonage ID:</label>
<input id="commonage_id" type="text" class="form-control" autofocus="autofocus"
placeholder="Enter ID here " />
<button id="submitButton" type="submit" class="btn btn-primary">View</button>
</div>
</form>
</div>
<span class="glyphicon glyphicon-exclamation-sign alert alert-danger"
id="ErrorMessage" style="display: none;" aria-hidden="true"></span>
<div id="loader" class="loader" hidden></div>
<div id="result_table" hidden>
<table class="table table-striped" id="herdTable">
<thead>
<tr>
<th class="threeTH">Herd Number</th>
<th class="threeTH">Share</th>
<th class="threeTH">Active Farmer</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
【问题讨论】:
-
请提供复制问题所需的 HTML 和 CSS。
-
可能是与 css 相关的问题。分享您的代码以了解
-
我现在已经更新了问题,当我删除 glyphicon 类时,文本似乎正确对齐,但图标也是如此
-
@MrLister 成功了,谢谢。您想将此作为答案发布,我会接受吗?
标签: html css glyphicons