开发者

right position an element that has already been left positioned

I have css class which sets a span to a particular left position.

left: 0.5em;

How do I override that left value to:

right: 0.5em;

...either inline or in another class?

in other words, how do yo开发者_运维技巧u set the left value to nothing or null?


Perhaps the answer is left: auto?

Live Demo


There are a few ways to approach this. If you just have one element you want to override, you can include different styling within that element. If you want to modify the CSS rule itself, the best approach is to use Javascript. All the CSS rules are stored in an array - document.styleSheets[i].cssRules. You can iterate over this and then update the appropriate rule as needed.

This blog post also has a nice tutorial that you might want to review: Updating CSS with Javascript

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜