Javascript 如何减少css中的填充?
我的html代码:Javascript 如何减少css中的填充?,javascript,html,css,Javascript,Html,Css,我的html代码: <div class="body" id="contact"> <form> <table> <tr> <td><label>Name</label></td> 它显示了一个大的间距,如何减少名称和文本框之间的空间 应该是 #contact { float: left; background: url(../images/separator-light-vert
<div class="body" id="contact">
<form>
<table>
<tr>
<td><label>Name</label></td>
它显示了一个大的间距,如何减少名称和文本框之间的空间
应该是
#contact {
float: left;
background: url(../images/separator-light-vertical.png) repeat-y right top;
height: 225px;
width: 254px;
padding: 20px 40px 0 20px;
}
由于它是一个
id
,您可以直接在css中使用id选择器
#contact{
float: left;
background: url(../images/separator-light-vertical.png) repeat-y right top;
height: 225px;
width: 254px;
padding: 20px 40px 0 20px;
}
同样,当浮动应用于元素时,它实际上会将其从文档流中移除,因此向其父元素添加填充不会对其产生影响。为“td”标记提供样式,(删除默认的填充和边距,然后为这些属性编写自定义样式)“
是类和属性
“#”
是ID
所以您使用的是
应该是:
#contact{
float: left;
background: url(../images/separator-light-vertical.png) repeat-right top;
height: 225px;
width: 254px;
padding: 20px 40px 0 20px;
}
更新:1
根据屏幕截图,我做了这个,希望这对你有用
代码:
<div class="body" id="contact">
<form>
<table>
<tr>
<td class="firsttd"><label>Name</label></td>
<td><input type=text></td>
</tr>
<tr>
<td class="firsttd"><label>Gender</label></td>
<td>
<input type=radio >Male
<input type=radio>Female
</td>
</table>
更新了HTML代码:
您正在应用的填充是:第一个是“顶部”,第二个是“右侧”,第三个是“底部”,最后一个是“左侧”,请记住,请尝试减少填充。它朝这个方向移动 应该是
div#contact
即使我添加了div#contact,它也不会显示任何更改代码中的文本框在哪里?上面的HTML代码会随着Gender删除表格而继续,但它不起作用。那么我怎么才能接受答案呢?上面的代码开始工作了,但是单选按钮之间有一个很大的空间。你可以删除div选择器并尝试分享fiddlehtml代码是Name css脚本是body{background:211917URL(../images/bg body.png)repeat-y center top;字体系列:“QuattrocentoSans Regular”;边距:0;}div#contact{float:left;background:url(../images/separator light vertical.png)repeat-y右上角;高度:225px;宽度:254px;}
<div class="body" id="contact">
<form>
<table>
<tr>
<td class="firsttd"><label>Name</label></td>
<td><input type=text></td>
</tr>
<tr>
<td class="firsttd"><label>Gender</label></td>
<td>
<input type=radio >Male
<input type=radio>Female
</td>
</table>
.firsttd{
width:auto;
}
.subtd{
width:auto;
}
#contact {
float: left;
background: url(../images/separator-light-vertical.png) repeat-y right top;
height: 225px;
width: 254px;
padding: 20px 40px 0 20px;
border:2px solid teal;
}