从 Telerik 控件中删除默认内联样式
使用 Telerik 控件时,如果我没有指定文本框的宽度,Telerik 将添加内联属性
style="width: 125px"
有没有办法阻止 Telerik 添加这样的默认值?
(注意:这不是从 telerik 控件中删除所有 CSS 的默认设置,询问如何删除默认样式表而不是内联样式)
When using Telerik controls if e.g. I don't specify a width for a textbox, telerik adds the inline attribute
style="width: 125px"
Is there a way to stop telerik adding default values like this?
(NOTE: This isn't a default of Removing all CSS from telerik controls, which is asking how to remove default stylesheets rather than inline styles)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
以下是 Telerik 的一些解决方案:
如何删除 RadInput 文本框的默认宽度或使用外部 CSS 设置它
Here are some solutions from Telerik:
How to Remove the Default Width of RadInput TextBoxes or Set it with External CSS
我不确定,但您可以尝试搜索样式表以查找输入的默认宽度规范。除此之外,您也许可以覆盖该属性并使用
!important
设置宽度。编辑
尝试将这样的样式添加到您的页面或样式表中。这可能不是 100%,但应该很接近:
编辑
如果您只需要设置一个控件的样式,请尝试以下操作:
I'm not sure, but you could try searching through the stylesheet(s) to find a default width specification for inputs. aside from that, you might be able to override the attribute and set the width using
!important
.EDIT
Try adding a style like this to your page or stylesheet. This might not be 100%, but it should be close:
EDIT
If you only need to style one control, try this:
这是我的最终实现,适用于 RadInput 和 RadComboBox。该功能需要适应每个控件,因为 Telerik 将样式放在不同的位置。
Here's a my eventual implementation, which works for RadInput and RadComboBox. The function needs adapting for each control as telerik put styles in varying places.
遇到了同样的问题,而且我不是 !important 覆盖或 JavaScript 解决方案的特别粉丝。
深入研究
RadInputControl
,我可以看到Unit.Pixel(160)
是默认的Width
,但前提是RenderMode
控件的宽度不是Lightweight
,因此切换到Lightweight
会删除显式内联宽度,否则,如果这不是 RadTextbox 的选项,我发现如果您设置Columns
属性0
它只输出This isn't看上去有效对我来说,所以我猜测大多数浏览器会忽略这一点,但我自己还没有广泛测试它。
Had the same issue and I'm not a particular fan of !important overrides or JavaScript solutions.
Digging into
RadInputControl
I could see thatUnit.Pixel(160)
is the defaultWidth
but only if theRenderMode
of the control is notLightweight
, so switching toLightweight
removes the explicit inline width, otherwise if that's not an option for the RadTextbox I found that if you set theColumns
property to0
it only outputsThis doesn't look valid to me, so I'm guessing that most browsers will ignore this, but I haven't tested it extensively myself.