在按钮内一行显示文字

Ale*_*xGH 1 html css twitter-bootstrap

我有一个带有一些文本的按钮,它在一行中显示文本,这是可以的,但是当我使用来display:block使按钮居中时,按钮居中,这很好,但是其中的文本有一个换行符并分为两行,我只希望文本显示在一行中:这是我的代码:

<div class="MyClass"><a type="button" style="margin:auto; display:block" class="ButtonLink" href="@Url.Action("MyAction","MyController")">Selected Now</a></div>
Run Code Online (Sandbox Code Playgroud)

当我有这样的代码时,文本显示在一行中,但是我需要将按钮居中:

<div class="MyClass"><a type="button" class="ButtonLink" href="@Url.Action("MyAction","MyController")">Selected Now</a></div>
Run Code Online (Sandbox Code Playgroud)

这就是我要的:

在此处输入图片说明

这就是当我将按钮居中时文本的显示方式:

在此处输入图片说明

我需要做什么?

Pra*_*man 5

您需要添加white-space: nowrap

<div class="MyClass">
    <a type="button" class="ButtonLink" href="@Url.Action("MyAction","MyController")">Selected Now</a>
</div>
Run Code Online (Sandbox Code Playgroud)
<div class="MyClass">
    <a type="button" class="ButtonLink" href="@Url.Action("MyAction","MyController")">Selected Now</a>
</div>
Run Code Online (Sandbox Code Playgroud)