How to centering list menu transforming from vertical to horizon

Hi guys,

I have a vertical list menu on the wider screens. I want to make it a horizon menu on smaller screens.
I also want to center those menus but they stick to the left.
How do I solve this?
Here’s my code:

<!DOCTYPE html>
<html>
	<head>
		<style>
			.list {
				position: fixed;
				right: 0;
				top: 8em;
				padding: 0.6em 0.4em;
				border: 0.07em solid #656565;
			}
			.list li {
				cursor: pointer;
				margin: 1em 0;
			}
			.list li:first-child { margin-top: 0; }
			.list li:last-child { margin-bottom: 0; }
			@media (max-width: 40em) {
				.list {
					position: static;
					padding: 0.6em;
				}
				.list li {
					display: inline-block;
					text-align: center;
					vertical-align: middle;
					margin: 0 0.3em;
				}
			}
		</style>
	</head>
	<body>
		<ul class=list>
			<li>B1</li>
			<li>B2</li>
			<li>B3</li>
		</ul>
	</body>
</html>

Thank you,

Never mind,

I solved this. I center the wrong place. It should be ul not li.

Sorry for stupid question. But I’ve tried this for two days.

1 Like

Glad you got there! I was confused by “horizontal” and “vertical”, because I was wondering if you had them around the wrong way, but never mind. Feel free to post your solution in case others are reading this and wondering how you did it. :slight_smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.