c# - Bootstrap 开关高度在回发后自动改变

标签 c# css asp.net bootstrap-switch

我有引导开关控件,可以打开和关闭 asp.net 元素中的某些面板。我的代码如下:

<div class="bootstrap-switch-container" id="div_pin_bscont" style="height: 34px!important">
    <span class="bootstrap-switch-handle-on bootstrap-switch-primary"></span>
    <span class="bootstrap-switch-label">&nbsp;</span>
    <span class="bootstrap-switch-handle-off bootstrap-switch-info"></span>
    <input type="checkbox" class="make-switch" data-on-color="primary" data-off-color="info" id="chx_pin_data" data-size="mini">
 </div>

构建后,我的标记代码如下所示:

<div class="bootstrap-switch-container" id="div_pin_bscont" style="height: 34px!important">
    <span class="bootstrap-switch-handle-on bootstrap-switch-primary"></span>
    <span class="bootstrap-switch-label">&nbsp;</span>
    <span class="bootstrap-switch-handle-off bootstrap-switch-info"></span>
    <div class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-mini bootstrap-switch-id-chx_pin_data bootstrap-switch-off bootstrap-switch-animate" style="width: 64px;"><div class="bootstrap-switch-container" style="width: 93px; margin-left: -31px;"><span class="bootstrap-switch-handle-on bootstrap-switch-primary" style="width: 31px;">ON</span><span class="bootstrap-switch-label" style="width: 31px;">&nbsp;</span><span class="bootstrap-switch-handle-off bootstrap-switch-info" style="width: 31px;">OFF</span><input type="checkbox" class="make-switch" data-on-color="primary" data-off-color="info" id="chx_pin_data" data-size="mini"></div></div>
 </div>

Control View before postback

但是在回发之后,这个控件的高度会自动增加。

Control View after postback

我试图通过标记或隐藏代码访问控件,但高度由构建添加的元素控制。我还挖掘了 css 文件,但没有出现。

感谢您的帮助。

最佳答案

这听起来很奇怪 一种解决方案应该是在您的 CSS 中为该元素定义一个静态高度,例如

div.bootstrap-switch-container {
    height: 25px;
}
.bootstrap-switch .bootstrap-switch-handle-on, .bootstrap-switch .bootstrap-switch-handle-off, .bootstrap-switch .bootstrap-switch-label  {
    padding: 3px 12px;
}
div.bootstrap-switch {
    margin-top: -4px;
}

如本文所引用 height issue in bootstrap switch , 您还可以检查元素并在浏览器中停用类,然后当您确定是哪个元素时,您可以在您的 css 文件中搜索该类

关于c# - Bootstrap 开关高度在回发后自动改变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57328387/

相关文章:

c# - 在使用委托(delegate)的多线程 winform 应用程序中,什么被认为是好的编程实践?

c# - 反序列化似乎不适用于 IDE 中的强命名对象

Javascript/Jquery 如何捕捉 CSS 类的使用

jquery - 使用 Less 通过实时预览更改 CSS 值

javascript - 未选中复选框时设置 div 背景色继承

c# - 响应由 JavaScript 完成的 TextBox 更改

c# - 在 WinRT 中将 JSON 对象反序列化为运行时类型 (C#)

c# - 如何根据调用方法的调用(按钮)发送者(按钮#)操作变量名称?

asp.net - 如何使用 bootstrap 使 ASP.NET 图表控件响应式

asp.net - 在 Asp.Net Core 中使用旧用户表的自定义身份验证