简体   繁体   English

更改其中存在的输入字段的背景颜色后,Fieldset顶部边框中断:仅在IE 11中

[英]Fieldset Top Border breaks after changing the background color of Input field present in it: Only in IE 11

Update 更新资料

I am facing an issue with fieldset top border in IE 11. 我在IE 11中遇到fieldset顶部边框的问题。

Description: I am having a fieldset in my web page. 说明:我的网页中有一个字段集。 Its legend tag contains a checkbox. 其图例标签包含一个复选框。 And its sub elements are input text fields. 其子元素是输入文本字段。 I have a JS which changes background color of input fields on checking/Unchecking checkbox present in legend. 我有一个JS,可更改图例中存在的选中/取消选中复选框的输入字段的背景颜色。

Problem: When background color of input field changes, Fieldset's top border breaks 问题:当输入字段的背景颜色更改时,Fieldset的顶部边框中断

Can anyone tell me why this is happening? 谁能告诉我为什么会这样吗?

Sample Code: 样例代码:

 function changeBackground() { document.getElementById("changeit").style.backgroundColor = "red"; } 
 table .td-left { width: 60%; text-align: left; } table .td-right { width: 40%; text-align: right; } 
 <fieldset> <legend> <input type="checkbox" onclick="changeBackground()"> <label>Hello</label> </legend> <table> <tr> <td class="td-right"> <label>Enter Text Here:</label> </td> <td class="td-left"> <input type="text" id="changeit"> </td> </tr> </table> </fieldset> 

The problem is caused by the checkbox in the legend, obviously. 问题显然是由图例中的复选框引起的。 Simply removing the checkbox from the legend makes it work fine. 只需从图例中删除复选框即可使其正常工作。

 function changeBackground() { document.getElementById("changeit").style.backgroundColor = "red"; } 
 table .td-left { width: 60%; text-align: left; } table .td-right { width: 40%; text-align: right; } 
 <fieldset> <legend> </legend> <div style="color:green; height:0; overflow:visible">Booh Booh Booh Booh Booh Booh Booh</div> <input type="checkbox" onclick="changeBackground()"> <label>Hello</label> <table> <tr> <td class="td-right"> <label>Enter Text Here:</label> </td> <td class="td-left"> <input type="text" id="changeit"> </td> </tr> </table> </fieldset> 

So what we need to do is make it look like the checkbox is in the legend, without it actually being in there. 因此,我们需要做的是使它看起来像图例中的复选框,而实际上不在其中。 How about this: 这个怎么样:

 function changeBackground() { document.getElementById("changeit").style.backgroundColor = "red"; } 
 table .td-left { width: 60%; text-align: left; } table .td-right { width: 40%; text-align: right; } fieldset label[for='flip']::before { content: ' ☐ '; } #flip { display: none; } #flip:checked+fieldset label[for='flip']::before { content: ' ☑ '; } 
 <input type="checkbox" id="flip" onclick="changeBackground()"> <fieldset> <legend> <label for="flip">Hello</label> </legend> <table> <tr> <td class="td-right"> <label>Enter Text Here:</label> </td> <td class="td-left"> <input type="text" id="changeit"> </td> </tr> </table> </fieldset> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM