我有這個隱藏的部分display:none。TextBox帶有控制元件的 div正在使用col-md-11,但是當切換顯示時,這部分看起來只占用了col-md-5. 我能做些什么來確保這是使用正確的空間嗎?
<div class="col-md-11 !important">
<div class="form-group">
<label class="control-label source-label">Other</label>
<input class="form-control" id="enteredOtherSource" name="enteredOtherSource[0].Other" type="text" value="">
<span class="field-validation-valid text-danger" data-valmsg-for="enteredOtherSource[0].Other" data-valmsg-replace="true"></span>
</div>
<input value="91" data-val="true" data-val-number="The field SourceId must be a number." data-val-required="The SourceId field is required." id="otherSourceId" name="enteredOtherSource[0].SourceId" type="hidden">
</div>

uj5u.com熱心網友回復:
display: none導致頁面呈現為好像該元素不存在,因此它將占用的空間被下一個元素填充。
visibility: hidden可以使用預留空間。
下面的作業片段顯示了三個 div 的集合,其中中間的一個被洗掉display:none或隱藏visibility:hidden
div {
width: 100%;
border: 1px solid black;
background: yellow;
padding: 3px;
}
.hidden {
visibility: hidden;
}
.none {
display: none;
}
.container {
width: 60%;
padding: 15px;
background: red;
border: 1px solid black;
}
<div class='container'>
Three normal divs, the middle one will have a style applied to hide or make it invisible in the lower panels
<div>1 - normal div </div>
<div>2 - none or visibility hidden below</div>
<div>3 - normal div </div>
</div>
<p> </p>
<div class='container'>
When using `display:none` the div and its space disappear:
<div>1 - normal div </div>
<div class="none">2 - display will be none</div>
<div>3 - normal div </div>
</div>
<p> </p>
<div class='container'>
when using `visibility: hidden` the div disappears but its space is reserved:
<div>1 - normal div </div>
<div class="hidden">2 - display will be none</div>
<div>3 - normal div </div>
</div>
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/464164.html
標籤:javascript 推特引导 引导程序 4
