HenryM HenryM - 2 months ago 6
CSS Question

How to centralise a button div

I want to centralise a button or a tag within the line it is on (by themselves).

I've written this CSS which makes it yellow, puts a border around it etc but it is always left aligned. How do I centralise it?

a.butt, button.butt {
border: 1px solid #ffff01;
background-color: transparent;
height:50px;
cursor:pointer;
padding-left: 40px;
padding-right: 40px;
padding-top: 10px;
padding-bottom: 10px;
text-decoration: none;
text-align: center;
color: #ffff01;
}


Thanks for your help

Answer

several ways to do this, but maybe

a.butt, button.butt {
 border: 1px solid #ffff01;
 background-color: transparent;
 height:50px;
 cursor:pointer;
 padding-left: 40px;
 padding-right: 40px;
 padding-top: 10px;
 padding-bottom: 10px;
 text-decoration: none;
 text-align: center;
 color: #ffff01;

 display: block;
 margin-left: auto;
 margin-right: auto;
 width: ??px;
}

will do the trick.