Reputation: 53
Is it possible with css' absolute positioning element to do something like:
.myElement{
width: 385px;
position: absolute;
left: 50% - 385px;
}
and have the element offset by a percentage minus its width, or something similar?
Upvotes: 5
Views: 3257
Reputation: 3369
you can also use calc:
.myElement{
width: 385px;
position: absolute;
left: **calc(50% - 385px)**;}
it's pretty much supported-> http://caniuse.com/#feat=calc
Upvotes: 4
Reputation: 4962
use a negative margin in the direction you want to go.
.myElement{
width: 385px;
position: absolute;
left: 50%;
margin-left: -385px;
}
Upvotes: 6