我想在文本后面加一个红色的星号。有没有办法在js代码中直接添加css代码?例如,类似于参数样式,但仅用于星号。我正在使用Extjs3.4
下面是代码。
{
xtype: 'label',
style: "font-size:11px;font-weight:bold;",
text: 'Note<span style="color:red">*</span> If any job applicant is failed,you can find it in the error log.',
// fieldLabel: 'Note<span style="color:red">*</span>: If any job applicant is failed,you can find it in the error log.',
},
如果我使用fieldLabel,则完整的文本仅在左侧打印。span适用于"fieldLable",但span不适用于"text"。
发布于 2017-02-15 16:40:21
使用html而不是text。
Ext.onReady(function() {
new Ext.FormPanel({
height: 100,
renderTo: Ext.getBody(),
items: [{
xtype: 'label',
style: "font-size:11px;font-weight:bold;",
html: 'Note<span style="color:red">*</span> If any job applicant is failed,you can find it in the error log.',
}]
});
});<link rel="stylesheet" href="https://cdn.sencha.com/ext/gpl/3.4.1.1/resources/css/ext-all.css">
<script type="text/javascript" src="https://cdn.sencha.com/ext/gpl/3.4.1.1/adapter/ext/ext-base-debug.js"></script><script type="text/javascript" src="https://cdn.sencha.com/ext/gpl/3.4.1.1/ext-all-debug.js"></script>
发布于 2017-02-15 16:29:34
在标签后添加面板为:
{
xtype: 'label',
forId: 'myFieldId',
text: 'Note',
},{
xtype:'panel',
html:'<span style="color:red;">*</span> If any job applicant is failed,you can find it in the error log.'
}发布于 2017-02-16 23:00:18
这是另一个解决方案。使用类和:之前。fiddle
https://stackoverflow.com/questions/42243348
复制相似问题