如何使用div对齐表格之类的表格?

发布于 2024-10-08 06:09:54 字数 384 浏览 0 评论 0原文

这是我的代码:

<div>
    <label>Name</label><input type="text" id='name'/><br />
    <label>Email</label><input type="text" id='email'/><br />
    <label>Place</label><input type="text" id='place'/><br />
</div>

我是 CSS 新手,我不希望表格对齐,但完美应该是一样的,并且不想将样式应用于单个元素。 任何帮助表示赞赏。

Here is my code:

<div>
    <label>Name</label><input type="text" id='name'/><br />
    <label>Email</label><input type="text" id='email'/><br />
    <label>Place</label><input type="text" id='place'/><br />
</div>

I'm new to CSS, I don't want table to get aligned, but the perfection should be like same, and don't want to apply style to individual elements.
Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小霸王臭丫头 2024-10-15 06:09:54

我假设您想要将标签和输入彼此对齐,在这种情况下您将需要浮动。这是快速的 css 代码:

form {
 width: 500px;
 overflow:hidden;}

label {
 clear: both;
 float: left;
 width: 40%;}

input {
 float: left;
 width: 55%;}

我认为应该可以:)

I'm assuming you want to align the labels and inputs next to one another, in which case you'll be needing floats. Here's the quick css code:

form {
 width: 500px;
 overflow:hidden;}

label {
 clear: both;
 float: left;
 width: 40%;}

input {
 float: left;
 width: 55%;}

I think that should work :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文