| | |
Horizontal centering issue with varying # of spans
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
OK, I guess this should be simple but I haven't been able to figure it out or find an answer. I am displaying a bar of "action buttons" that are spans. I need these action buttons to center, there can be anywhere from 2 to 7 of them. I can get some centering using fixed width but since the number of buttons varies this doesnt really work. I have no problem adding or changing container types. See the HTML and CSS below...
Please help and thanks!!
The HTML:
The CSS:
Please help and thanks!!
The HTML:
html Syntax (Toggle Plain Text)
<div class="widgetWrapper"> <div class="widgetWrapperTopHalf"> <div class="widgetName">Widget Name</div> <div class="widgetDescription">This is some kind of widget</div> <div class="widgetThumb"> <img class="widgetThumbImage" src="http://www.reel.com/Content/reelimages/reviews/200x130_simpsons_6.jpg" /> </div> </div> <div class="widgetWrapperBottomHalf"> <div class="widgetActionBar"> <span class="widgetActionButton" style="color:red;" title="action1">A</span> <span class="widgetActionButton" style="color:blue;" title="action2">B</span> <span class="widgetActionButton" style="color:white;" title="action3">C</span> <span class="widgetActionButton" style="color:black;" title="action4">D</span> </div> </div> </div>
The CSS:
css Syntax (Toggle Plain Text)
<style type="text/css"> .widgetWrapper { display:block; float:left; margin-left:7px; margin-top:7px; padding-top:10px; padding-right:5px; padding-left:5px; border-right:solid 1px #CFCFCF; border-left:solid 1px #ECECEC; border-bottom:solid 2px #CFCFCF; border-top:solid 1px #ECECEC; height:350px; width:250px; text-align:center; } .widgetWrapperTopHalf { display:block; height:80%; width:100%; } .widgetWrapperBottomHalf { display:block; height:20%; padding:0; width:100%; float:right; text-align:center; } .widgetName { position:relative; font-size:11px; font-weight: Bold; color: #000000; text-align:center; display:block; clear:both; white-spacere-wrap; margin-top:-10px; } .widgetThumb { width:100%; display:block; margin-top:5px; padding:0px; } .widgetThumb img { cursorointer; } .widgetActionBar { clear:both; display:block; height:24px; width:100%; text-align:center; } .widgetActionButton { /* position:relative;*/ float:left; display:table; clear:none; height:20px; width:17px; margin-left:5px; margin-right:5px; padding-left:2px; cursorointer; background-color:#C0C0C0; border-top:solid 1px #bababa; border-left:solid 1px #bababa; border-right:solid 2px #455769; border-bottom:solid 2px #455769; } </style>
We must accept finite disappointment, but never lose infinite hope. -- Martin Luther King, Jr.
•
•
Join Date: Jun 2004
Posts: 247
Reputation:
Solved Threads: 1
make the margin for widgetWrapper like this
or
HTML and CSS Syntax (Toggle Plain Text)
margin:0 auto;
HTML and CSS Syntax (Toggle Plain Text)
margin-left:auto; margin-right:auto;
•
•
•
•
make the margin for widgetWrapper like this
orHTML and CSS Syntax (Toggle Plain Text)
margin:0 auto;
HTML and CSS Syntax (Toggle Plain Text)
margin-left:auto; margin-right:auto;
Thanks for replying though!
I actually received the answer on another forum I posted on. For anyone curious here was the solution, the .widgetActionButton CSS class was changed.
css Syntax (Toggle Plain Text)
.widgetActionButton { height:20px; width:17px; display: table-cell; display: inline-table; display: inline-block; margin-left:5px; margin-right:5px; padding-left:2px; cursor:pointer; background-color:#C0C0C0; border-top:solid 1px #bababa; border-left:solid 1px #bababa; border-right:solid 2px #455769; border-bottom:solid 2px #455769; }
Last edited by waycool141; Feb 12th, 2009 at 11:19 am.
We must accept finite disappointment, but never lose infinite hope. -- Martin Luther King, Jr.
![]() |
Other Threads in the HTML and CSS Forum
- Previous Thread: css drop down menu not working in i.e 7
- Next Thread: CSS Dropdown Menu - How to highlight current page button ??
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization perl pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7 xml xsl





