The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> menu help
hobbsmiely
post Jun 26 2015, 03:50 PM
Post #1





Group: Members
Posts: 1
Joined: 26-June 15
Member No.: 22,782



hi, i made this menu bar, and it looks great, but it's aligned to the left, is there any way to fix the code so that it centers? also can you tell me where the style part is supposed to be entered on the page, should it be between the head elements? i wanted to do two seperate ones on my page, one like this and one thats linked to actual images, but they conflict with each other.

Very new at this so please be gentle LOL

<div id="cssmenu">
<ul>
<li><a href="index.htm"><span>Home</span></a>
</li>
<li><a href="#theresort"><span>The Resort</span></a>
</li>
<li><a href="#directions"><span>Directions</span></a></li>
<li><a href="#campfeatures"><span>Camp
Features</span></a></li>
<li><a href="#activities"><span>Activities</span></a></li>
<li><a href="#cabins"><span>Cabin Rates</span></a></li>
<li><a href="#campsites"><span>Campsite
Rates</span></a></li>
<li><a href="#rentals"><span>Rentals</span></a></li>
<li class="last"><a href="#contact"><span>Contact
Us</span></a></li>
</ul>
</div>


<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
li {
float: left;
}
a:link, a:visited {
display: block;
width: 120px;
font-weight: bold;
color: #00FFFF
background-color: rgb(195, 241, 241);
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
}
a:hover, a:active {
background-color: #002EB8
}
</style>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jun 26 2015, 10:21 PM
Post #2


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Since the menu doesn't have a width you can't center it with auto margins. If you don't want to give it a with you can make it inline-block instead and then it can be centered as inline content.

CODE
#cssmenu   { text-align: center }
ul         { display: inline-block }
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post Jun 27 2015, 03:52 PM
Post #3


🌟Computer says no🌟
********

Group: WDG Moderators
Posts: 20,730
Joined: 9-August 06
Member No.: 6



Sorry, I type faster than I read sometimes and there's crumbles in my keyboard.

I wrote the below.

Since the menu doesn't have width you can center it with auto margins.

Which is of course a peculiar thing to say. I meant to write the below.

Since the menu doesn't have a width you can't center it with auto margins.

I corrected it in my post above to avoid further confusion. blush.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 23rd April 2024 - 09:24 PM