The scenario involves centering an unordered list (
Apply the following CSS styles to the "wrapper" class:
.wrapper { text-align: center; }
This centers the "wrapper" div and aligns the
Apply the following CSS styles to the
.wrapper ul { display: inline-block; margin: 0; padding: 0; /* IE support */ zoom: 1; *display: inline; }
This makes the
Apply the following CSS styles to the
.wrapper li { float: left; padding: 2px 5px; border: 1px solid black; }
This ensures that the
<style> .wrapper { text-align: center; } .wrapper ul { display: inline-block; margin: 0; padding: 0; zoom: 1; *display: inline; } .wrapper li { float: left; padding: 2px 5px; border: 1px solid black; } </style> <div class="wrapper"> <ul> <li>Element 1</li> <li>Element 2</li> <li>Element 3</li> </ul> </div>
The above is the detailed content of How to Center an Unordered List within a Fixed-Width Div?. For more information, please follow other related articles on the PHP Chinese website!