Reputation:
I want the position of image to be center.I used the center
tag & text-align but its not working.Please help
CSS:
#indtrans
{
position :fixed;
display:block;
background-color : none;
top: 2px;
text-align:center;
padding-left:130px;
}
html:
<center><div id="indtrans"><img src="indeximg.png"></img></div></center>
Upvotes: 0
Views: 136
Reputation: 126
Because you are positioning your #indtrans
DIV with position fixed, you will need to be more specific in your alignment. Simply using margin: 0 auto;
will not work.
Instead try this. The margin left will need to be a minus of 50% of the total width of your element.
#indtrans
{
position :fixed;
display:block;
background-color : none;
top: 2px;
left: 50%;
margin-left: (-50% of total width);
text-align:center;
padding-left:130px;
}
Upvotes: -1
Reputation: 857
Try this:
#indtrans
{
display: block;
left: 50%;
position: fixed;
top: 2px;
}
Upvotes: 0
Reputation: 26969
Add width:100%
Change css like this
#indtrans{
position :fixed;
display:block; width:100%;
background-color : none;
top: 2px;
text-align:center;
padding-left:130px;
}
Upvotes: 0
Reputation: 209
if you give the div a set width, then you should be able to set a margin: 0 auto; which would center it.
Upvotes: 2