I want my anchor tag look like a button, and created this style JsFiddle
.details-button {
background: linear-gradient(to bottom, #FFFFFF 0, #FAB149 2%, #F89406 100%) repeat scroll 0 0 transparent;
border: 1px solid #FAB149;
-ms-border-radius: 3px;
border-radius: 3px;
-webkit-box-shadow: 0 1px 2px #999999;
-ms-box-shadow: 0 1px 2px #999999;
box-shadow: 0 1px 2px #999999;
color: #FFFFFF;
cursor: pointer;
font-family:"Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 13px;
font-weight: bold;
-ms-text-shadow: 0 -1px #099FDF;
text-shadow: 0 -1px #099FDF;
margin: 4px;
height: 28px;
width: 85px;
vertical-align: central;
align-items: center;
text-decoration: none;
font: menu;
display: inline-block;
/*padding: 6px 0 5px 18px;*/
}
It looks as I want, but how to center text horizontally and vertically inside anchor tag?
text-align: center; Finally, make your height auto and instead of a line-height declaration, set the padding to taste: height:auto; padding:3px 0; That should do it!
One way to center text or put it in the middle of the page is to enclose it within <center></center> tags. Inserting this text within HTML code would yield the following result: Center this text!
To just center the text inside an element, use text-align: center; This text is centered.
You should center the content using text-align . There is no need for flex here, as flex actually tries to put several elements on one line.
Add
text-align: center;
line-height: 28px;
working demo: http://jsfiddle.net/3SE8L/2/
line-height
and padding
work if the height of the element is hard-coded, but I like to use
{
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
}
to keep text centered in a tags where the height may change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With