admin管理员组文章数量:1326061
I am trying to center tags within a div but depending on what page you are on it can depend on how many tags there will be as it's for an image gallery. So i am trying to do it with Jquery.
Basically what i want to say is:
For every tag add 5% to the margin.
Can someone point me in the right direction to do so. I was thinking of using the .size() to calculate the amount of tags but not sure where to go then.
Thanks.
I am trying to center tags within a div but depending on what page you are on it can depend on how many tags there will be as it's for an image gallery. So i am trying to do it with Jquery.
Basically what i want to say is:
For every tag add 5% to the margin.
Can someone point me in the right direction to do so. I was thinking of using the .size() to calculate the amount of tags but not sure where to go then.
Thanks.
Share Improve this question asked Mar 19, 2012 at 11:39 JDaviesJDavies 2,7707 gold badges36 silver badges55 bronze badges 3- 1 provide some code sample – Amit Soni Commented Mar 19, 2012 at 11:41
- Do you mean you want the margin to be 5% per item in the div (so 3 items == 15%), or just 5% margin on each item? – Matt Sach Commented Mar 19, 2012 at 11:45
- Ill post an answer but im not sure if it is what you need? I think you mean: For x amount of tags add 5% margin to each? Or x amount of tags * 5% = margin on a certain element? – Undefined Commented Mar 19, 2012 at 11:45
1 Answer
Reset to default 7Use the *
selector
$("*").css("margin","5%");
However, for the safety purposes, you have to limit the use of such wildcard selector. There are lots of other ways you can select mass elements.
- Class Selecotors:
$(".myclass')
- Tag Selecotors:
$("div")
- Atrribute:
$("input[type="text"]')
本文标签: javascriptAdding margin with JqueryStack Overflow
版权声明:本文标题:javascript - Adding margin with Jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742197641a2431374.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论