c# - 回发后引导开关高度自动更改
问题描述
我有引导开关控件,可以打开和关闭 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"> </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"> </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;"> </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>
但是在回发之后,这个控件的高度会自动增加。
我试图通过标记或代码访问控件,但高度由构建添加的元素控制。我也挖掘了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;
}
正如bootstrap switch 中的这篇帖子高度问题所引用的 ,您还可以在浏览器中检查元素并停用类,然后当您确定哪个在制作它时,您可以在您的 css 文件中搜索该类
推荐阅读
- python - 我的电报机器人使用 opencv 从相机接收图像给我一个错误并且不起作用
- python - 如何在 python 中编写 if、else 语句以将数据字符串附加到目录中的特定文件?
- datatable - 将分号视为primefaces OutputText中的分隔符
- authentication - 使用 AddCookies 中间件时未生成 Cookie
- java - Heroku 上的 JVM 内存不一致
- .htaccess - 将查询字符串转换为 seo 友好的 url 但允许其他查询字符串
- swift - 无法从 Firestore 获取数据
- azure-devops - 生成 Azure DevOps 发行说明
- mysql - 如何在 mysql/mariadb 中隐藏版本和名称?
- python - Django从url加载图像-反对的ImageField没有属性_committed