我想创建一些纯CSS社会登录按钮。中心对齐按钮,但左对齐内部文本
但我无法弄清楚如何让文本左对齐,同时居中按钮。
“使用Facebook登录”的文本比“使用Google登录”的文本长,因此当按钮堆叠在一起时文本不排列。
我希望文本中心在按钮内对齐,但我希望它左对齐,以便每个按钮的单词“登录”排队。
这里是什么,我想达到的截图例如:
这里有一个类似的问题和解决办法,但我可以把它用的HREF不div的工作不是:CSS: Center block, but align contents to the left
.shell {
text-align: center;
}
.social-connect-button {
display: inline-block;
text-decoration: none;
line-height: 2.65em;
display: block;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
-ms-border-radius: 5px;
-o-border-radius: 5px;
border-radius: 5px;
font-size: 18px;
color: #fff!important;
}
.fb-login {
background-color: #3b589e;
margin-bottom: .7em;
}
.google-login {
background-color: #dd4c39;
cursor: pointer;
}
.fb-login i {
float: left;
background: #37528C;
padding: 0 .4em;
border-radius: 5px 0 0 5px;
}
.google-login i {
float: left;
background: #37528C;
padding: 0 .4em;
border-radius: 5px 0 0 5px;
}
.social-connect-button span {
margin-left: .875em;
margin-right: .875em;
}
<div class="shell">
<a class="social-connect-button fb-login" href="[facebook-login-url]">
<i>ICON</i>
<span>Login with Facebook</span>
</a>
<a class="social-connect-button google-login" href="[google-login-url]">
<i>ICON</i>
<span>Login with Google</span>
</a>
</div>
根据你所描述的,我不认为你可以实现不同长度的按钮文本的这两种方案。 – Stickers
图像和你的代码的结果看起来类似于我,只是宽度在你的情况很长:/ – AVI