Jump to content

how to verticaly center abutton in a div


otuatail

Recommended Posts

	<div style="height:40px;width:300px;margin-top:15px;clear:both;border:solid;">
    <input type="submit" value=" Update Teams ">
    </div>

Hi I have tried margins and borders both top and bottom

 

I just want the submit button vertically centred.

 

This is part of  another div hence the clear:both;

 

TA :)

 

Driving me mental...

Edited by otuatail
Link to comment
Share on other sites

Try this in your CSS:

#my-button{
	position: absolute;
	top: 50%;
	-ms-transform: translateY(-50%);
	-webkit-transform: translateY(-50%);
	transform: translateY(-50%);
}

Obviously change the #my-button identifier to whatever ID you're using for the button, and make sure the surrounding container has a position: value of either 'absolute' or 'relative'.

Link to comment
Share on other sites

I simply added the display and vertical-align attr to your code and tested fine in firefox.

<div style="height:40px;width:300px;margin-top:15px;clear:both;border:solid;display: table-cell;vertical-align: middle">
        <input type="button" value=" Update Teams " style="">
    </div>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.