Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

asp.net - Asp:CheckBox checkbox and text are not on the same line

I can't seem to figure out how to get the checkbox and associated text to appear on one line. The text is very short so it doesn't seem to be a width issue. I tried setting display:inline on the control but when it's rendered, a span is added around the input and label and that has the display:inline. If I manually add the display:inline, using the resources view in Chrome, to the resulting label than it's fine. The problem is I don't know how to get the control to do this.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You want to have display:inline applied to the <label> element that ASP generates to hold the label text, not the control itself. So, for example:

<style type="text/css">
    label { display: inline-block; }
</style>
<asp:CheckBox Text="This text appears on same line as checkbox" runat="server" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...