Can you anyone please help me to code this below one
This is my current code
<div id="loginBtn" class="loginBtn"><span>Log in</span></div>
div tag have loginBtn class and span tag having "log in" text in html page
.loginBtn { background:url(images/loginBtn-center.jpg) repeat-x; width:175px; height:65px; margin:20px auto; border-radius:10px; -webkit-border-radius:10px; box-shadow:0 1px 2px #5e5d5b; }
I created the button using 1px image. Now i am unable to place the "log in" text middle of the image can any one help me complete the code
text is displaying left top corner. Please help me.
Center Align Text To just center the text inside an element, use text-align: center; This text is centered.
Answer: Use the text-center Class You can simply use the built-in class . text-center on the wrapper element to center align buttons or other inline elements in Bootstrap.
You need to take the float:left off of both your #nav and li elements. Then add display:inline-block; to both. Next add your text-align:center to the #nav .
You can use text-align: center; line-height: 65px;
Demo
CSS
.loginBtn { background:url(images/loginBtn-center.jpg) repeat-x; width:175px; height:65px; margin:20px auto; border-radius:10px; -webkit-border-radius:10px; box-shadow:0 1px 2px #5e5d5b; text-align: center; <--------- Here line-height: 65px; <--------- Here }
This is more predictable then "line-height"
.loginBtn { background:url(images/loginBtn-center.jpg) repeat-x; width:175px; height:65px; margin:20px auto; border-radius:10px; -webkit-border-radius:10px; box-shadow:0 1px 2px #5e5d5b; } .loginBtn span { display: block; padding-top: 22px; text-align: center; line-height: 1em; }
<div id="loginBtn" class="loginBtn"><span>Log in</span></div>
.loginBtn { display: flex; align-items: center; justify-content: center; }
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