C# 文本和复选框之间的空间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12917897/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
space between text and checkbox
提问by
I want to have space between checkbox and the text.
我想在复选框和文本之间留出空间。
<asp:CheckBox ID="chkPublic" runat="server" Text="Public" Font-Bold="true" />
How to get space between checkbox and text. Thanks.
如何获得复选框和文本之间的空间。谢谢。
EDIT: I need some css format. Thanks.
编辑:我需要一些 css 格式。谢谢。
采纳答案by tutts
<asp:CheckBox ID="chkPublic" runat="server" Text="Public" Font-Bold="true" CssClass="mycheckbox" />
In stylesheet.css
在 stylesheet.css 中
.mycheckbox input[type="checkbox"]
{
margin-right: 5px;
}
回答by KeepAlive
You could write it like this:
你可以这样写:
<asp:CheckBox ID="chkPublic" runat="server" Text="" Font-Bold="true" /> MyText
Or maybe just like that:
或者就这样:
<asp:CheckBox ID="chkPublic" runat="server" Text=" Public" Font-Bold="true" />
is a single space in html
是 html 中的单个空格
回答by Catholic Con
I created a style for the label:
我为标签创建了一个样式:
label {
font-size: 1em;
color: black;
text-transform: uppercase;
margin-left: 5px;
}
However it will affect the header labels so I also created a style as well:
但是它会影响标题标签,所以我也创建了一个样式:
.lheader {
font-size: 1.5em;
color: #1ca795;
text-transform: uppercase;
}
It worked perfectly on all devices.
它在所有设备上都能完美运行。
回答by Not the famous Martin
A late reply, but hopefully helpful to someone else looking for a solution. You can "quick-and-dirty" add space by embedding non-breaking spaces in the text property value. The advantage is that you can do this for controls that are exceptions to the styles applied elsewhere without having to create a new style sheet for just one control. For example:
回复较晚,但希望对其他人寻求解决方案有所帮助。您可以通过在文本属性值中嵌入不间断空格来“快速而肮脏”地添加空格。优点是您可以对在别处应用的样式例外的控件执行此操作,而无需仅为一个控件创建新的样式表。例如:
<asp:CheckBox runat="server" ID="myCheckBox" Text=" Check this to subscribe" />

