These are instructions on how to make an HTML link or button expand to be as wide as its parent element. Maybe you have been confused in the past and that darn link just never wants to grow.
Here is the CSS you are going to want to apply to that link.
text-align:center; /*This will result in centering the link text, which is probably what you want -brianjohnsondesign.com*/
And the corresponding HTML:
<a href="#" class="fullwidth">Subscribe now</a>
The secret here is that you need to use display:block; to actually force the button to grow to the full width. You also can’t really use left or right margins or padding, as they will just mess up the width and cause it to be off-center or larger than its container. Top or bottom margins or padding won’t cause any problems, however.
Keep in mind, as well, you need to make sure that the parent div or element of the link must be the width you are trying to force this button to be. Check and make sure it has a width!
This doesn’t work if you want a margin on the side of your button. I found that you can work around this by using:
width: calc(100% – 6em);
where you set your subtraction distance (as in 6em above) along with your margins to give the appropriate appearance that you want.
Seems to just be centering my Button, any ideas?
Have you verified that the parent element above your button is any wider?
Thank you , usefull css tip
Glad I could help!
Thanks for this!
Thanks for that!
Pingback: [RESOLVED]linkbutton width | Asp Forum
Great tip, Just what I needed to make my clients sites CSS Links / Buttons look right for my design.