Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

CSS Center align Divs

I have a section of a page that can have up to five boxes across that contain dynamic content.  Right now I have the bo class floating left.  However, if I have 1, 2 or 3 boxes I want them to center on the page, not float.  How do I do that?

.related-product-box {
	padding:1%;
	width:23%;
	text-align:center;
	float:left;
}

Open in new window

Avatar of Francisco Igor
Francisco Igor
Flag of Canada image

Try using relative margin. See an example  at https://jsfiddle.net/FranIg/2tmvvqoj/

.related-product-box {
	padding:1%;
	width:24%;
	text-align:center;
	float:left;
        margin: 3%;
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial