【发布时间】:2019-05-27 11:49:01
【问题描述】:
我创建了一个表,我希望用户能够在其中提供输入。 Now when a td is selected/focused i want to turn the border around it in a color.我已经尝试过了,但是当我这样做时,即使我将填充设置为 0,它也会在输入字段和 td 之间留下一个很小的间隙。
@import url('https://fonts.googleapis.com/css?family=Lato:400,700,900');
body {
font-family: "Lato", sans-serif;
}
input {
width: 120px;
height: 20px;
border: 1px;
padding: 5px;
outline: none;
}
input:focus {}
table {
margin: 50px;
font-weight: 400;
border-collapse: collapse;
}
th {
font-size: 20px;
}
td:focus {
border: 1.5px solid orange;
}
td,
th {
font-weight: 900;
width: 120px;
border: 1px solid #dddddd;
text-align: left;
padding: 0;
}
<body>
<table>
<tr>
<th>Income</th>
<th>Outgoings</th>
<th>Taxes</th>
<th>Total</th>
</tr>
<tr>
<td><input type="text" placeholder="CHF"></td>
<td><input type="text" placeholder="CHF"></td>
<td><input type="text" placeholder="CHF"></td>
<td><input type="text" placeholder="CHF"></td>
</tr>
我希望有人可以帮助我。
【问题讨论】:
-
input:focus {}是什么意思? -
1.5px solid orange...1.5px 像 1 px 和其他一半? -
你试过
input:focus {box-shadow: 0 0 0 1px orange;}吗? -
你可以使用
<td contenteditable="true">而不是输入元素 -
@enxaneta contenteditable 是一个野兽,它可以多行、添加标签、粗体、斜体、制作咖啡和其他不需要的东西。
标签: html css html-table border