我遇到問題。如何防止寬度爲100%的輸入溢出?
我有一組顯示像一個表格,它有一個行和3列的div。
這些div在達到768px的最大寬度時會作出響應,第1列將被隱藏,第2列和第3列將保留,並且將具有輸入文本。該輸入文本將有一個標籤,該標籤將顯示爲內嵌文本。
我的問題是輸入有一個100%的CSS,但輸入的文本超出了表格的範圍。
下面的代碼
/* DivTable.com */
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.divTable{
\t display: table;
\t width: 100%;
}
.divTableRow {
\t display: table-row;
}
.divTableHeading {
\t background-color: #EEE;
\t display: table-header-group;
}
.divTableCell, .divTableHead {
\t border: 1px solid #999999;
\t display: table-cell;
\t padding: 3px 10px;
}
.divTableHeading {
\t background-color: #EEE;
\t display: table-header-group;
\t font-weight: bold;
}
.divTableFoot {
\t background-color: #EEE;
\t display: table-footer-group;
\t font-weight: bold;
}
.divTableBody {
\t display: table-row-group;
}
.form-control {
width: 100%;
height: 34px;
padding: 6px 12px;
font-size: 14px;
line-height: 1.42857143;
color: #555;
background-color: #fff;
background-image: none;
border: 1px solid #ccc;
border-radius: 4px;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
-webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
@media (max-width: 768px) {
.hide1 {
display:none;
}
.force-display {
display:block;
}
.forcew {
white-space:nowrap;
}
}
<div class="divTable" style="width: 100%;border: 1px solid #000;" >
<div class="divTableBody">
<div class="divTableRow">
<div class="divTableCell hide1"><p class="f-bold override" style="">First Name:</p></div>
<div class="divTableCell force-display">
<div class="forcew">
<label>First Name:</label>
<input type="text" class="form-control" id="firstName" name="firstName" placeholder="First" value="$!CQS0013.firstName" required/>
</div>
</div>
<div class="divTableCell force-display">
<input type="text" class="form-control" id="firstName" name="firstName" placeholder="First" value="$!CQS0013.firstName" required/>
</div>
</div>
</div>
</div>
這裏的小提琴: https://jsfiddle.net/bt6hrc4h/
與溢出隱藏包裝在一個div! – Gacci