两个input框设置左右间距
时间: 2024-01-17 20:04:19 浏览: 65
可以使用CSS中的margin属性来设置两个input框的左右间距。例如,如果要设置两个input框之间的间距为20像素,可以这样写:
```css
input {
margin-right: 20px;
}
input:last-child {
margin-right: 0;
}
```
这样,除了最后一个input框外,其他input框都会有右侧20像素的间距。同时,最后一个input框不需要间距,所以需要将其margin-right属性设置为0。
相关问题
两个input框设置上下间距
你可以使用CSS的margin属性来设置上下间距。比如,如果你有两个input框,可以在第一个input框的CSS样式中设置下边距,同时在第二个input框的CSS样式中设置上边距,如下所示:
```css
input:first-child {
margin-bottom: 10px;
}
input:last-child {
margin-top: 10px;
}
```
上面的代码将在第一个input框的下面添加10像素的空白,同时在第二个input框的上面添加10像素的空白。你可以根据需要调整这些值。
html 两个input垂直排成一列的间距
可以使用 CSS 的 `margin` 属性来设置两个 input 垂直排列时的间距。例如,以下代码可以让两个 input 元素之间的间距为 10 像素:
```html
<input type="text" placeholder="Input 1">
<input type="text" placeholder="Input 2" style="margin-top: 10px;">
```
在第二个 input 元素中,使用了 `margin-top` 属性来设置上边距为 10 像素。你可以根据需要自行调整这个值。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)