So... this is starting to annoy me ... and I thought i would come here and get some help..
The main div around the box has a width... then there is text... and a button that i want in the center of the div..
it is a <a href>
button.. but it wont center.
I didn't think I would need to specify a width since the outside div has a width.. i tried margin:0 auto; text-align:center
etc nothing works
<h2 class="service-style color_service">Annoyed</h2>
<div class="service-text text1">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua Lorem ipsum dolor sit amet…
</p>
<a href="" class="button button-large"><i class="fa fa-credit-card" style="padding-right:10px;"></i> Learn More</a>
</div>
here is the fiddle link
Wrap the button in an element and give it
text-align:center
.Write:
Updated fiddle here.
Try this
DEMO
Your button needs to be a block level element. Simplest fix:
http://jsfiddle.net/jqvbM/
I would also delete the 10px right margin on
a.button-large i
to center the "Learn More" text.You need to put the text-align:center; to the parent element of the button in your case is the div.service-text.
if you want the top P to be text-align:right; please use diffrent P to the button
remember. if your element is display:block; so you need to give margin: 0 auto; to your element. if your element is display:inline-block; you need to give text-align:center; to the parent element.
check fiddle here
you have to modify your css like below: - remove
margin
froma.button-large
class - and changedisplay:table
in.button
classI would suggest dialing it back a little and divorce yourself from your framework or whatever you are using. To center things horizontally there are 2 approaches.
You have to decide based on whether you want the button to be position: inline, inline-block, or block. For mobile and fingers and all that stuff(2014) - I would suggest inline-block or block. So -
if it's inline block, then you can just treat it like text. Set the parent to
text-align center;
If it's block, then you you can use
margin-right: auto; margin-left: auto;
but that has other issues. Like all the other thinks near it need to be organized properly so that they don't float all over each other and screw everything up. I would suggest you do it like this: jsfiddlePS - we don't need to see so much code in your fiddle. It's easier to get to the rout of the problem with only the bare necessities. Good luck.
HTML
CSS