gpt4 book ai didi

javascript - HTML 如何填充内容

转载 作者:太空宇宙 更新时间:2023-11-04 03:49:00 25 4
gpt4 key购买 nike

我正在尝试制作一个“Pad”,但我完全不知道该怎么做。

如果您转到 Fiddle,您会看到“内容”被填充。这是故意的,我知道如何用 table 做到这一点。

但是,对于包含部分的 javascript,我发现如果我包含一个表,则无论脚本和 div 标记如何,所有内容都会显示,这不是我想要的。

我需要找到一种方法来填充“内容”之后的部分,使其对齐。也许我构建的表格不正确,在这一点上,我更好奇如果不使用 HTML 中的表格如何做到这一点。

非常感谢任何帮助。

Javascript:

function selection(){
var myEvaluator = addendaList.options[addendaList.selectedIndex].value;
var referenceNumberId = document.getElementById("referenceNumberBlock");
var deliveryIdentificationId = document.getElementById("deliveryIdentificationBlock");
var currencyISOCodeId = document.getElementById("currencyISOCodeBlock");
var referenceTrafficId = document.getElementById("referenceTrafficBlock");

if( myEvaluator == "IMP" ) {
referenceNumberId.style.display = "block";
deliveryIdentificationId.style.display = "block";
currencyISOCodeId.style.display = "none";
referenceTrafficId.style.display = "none";
} else if ( myEvaluator == "EXP" ) {
referenceNumberId.style.display = "none";
deliveryIdentificationId.style.display = "none";
currencyISOCodeId.style.display = "block";
referenceTrafficId.style.display = "block";
}
}

HTML

<body>
<table width="620" align="center" cellpadding="0" cellspacing="0">
<td width="160" valign="top">
<b>Content</b>
</td>
</table>

<b>Select an option: </b>
<select name = "code" id = "addendaList" onChange = "select()">
<option value = "IMP">Import</option>
<option value = "EXP">Export</option>
</select>

<div ID = "referenceNumberBlock" style = "display:block;">
<b>Reference Number: </b>
<input name = "referenceNumber" id = "referenceNumber" type = "text" size = "16" maxlength="15" value = "">
</div>

<div ID = "deliveryIdentificationBlock" style = "display:block;">
<b>Delivery Identification: </b>
<input id = "deliveryIdentification" name = "deliveryIDentification" type = "text" size = "16" maxlength = "30" value = "">
</div>

<div ID = "currencyISOCodeBlock" style = "display:none;">
<b>Currency ISO Code: </b>
<select id = "ISOCodes" name = "currencyISOCode">
<option value = "MXN">MXN</option>
<option value = "USD">USD</option>
</select>
</div>

<div ID = "referenceTrafficBlock" style ="display:none;">
<b>Traffic Number: </b>
<input name = "referenceTraffic" type = "text" size = "16" maxlength = "20" value = "">
<div>
</body>

fiddle :http://jsfiddle.net/tL98L/4/

更新的 Fiddle 解决了: http://jsfiddle.net/tL98L/18/

最佳答案

<div class="wrapper"> 包围您想要填充的所有内容并将其添加到您的 CSS 中:

.wrapper { padding-left: 15px }

这应该行得通

关于javascript - HTML 如何填充内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23676050/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com