开发者

CSSing HTML form layout (Equal widths for labels/inputs)

I'm trying to create the following CSS rules for my HTML form layouts:

  1. Each label and corresponding input element take up 50% of width respectively:

|label | input |

  1. I want to be able to justify labels to开发者_JAVA技巧 right or left. (Inputs will always justify left.)

Something I've noticed- Label widths don't seem to be able to be set by CSS?

Any good ideas? Thanks


Your label needs to be floating:

label {
    float: left;
    width: 100px; /* change this to whatever you want */
    /* these make it look nicer */
    text-align: right;
    padding-right: 10px;
}

You'll need something below it to clear the float as well, but this should do the trick.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜