- This topic is empty.
-
AuthorPosts
-
February 12, 2014 at 7:34 am #162688
vpatterson
ParticipantWhen you view my page in full screen the navigation bar looks center but when you resize my page it is no longer center. I need help with my CSS code because I know the error is in there. Can someone please help me?
my code is below:
CSS:
.center { margin-left:36.5%; margin-right:50%; width:100%; background-color:#b0e0e6; text-align: center; vertical-align:middle; } ul { padding:0; margin:0; list-style: none; background:#000; height:36px; text-align:center; } ul li { float:left; position:relative; } a:link, a:visited { text-decoration: none; color: #FFF; font-weight:bold; } ul li a, ul li a:visited { display:block; color:#fff; width:auto; height:auto; line-height:20px; padding:10px; text-align:center; } ul li a:hover { display:block; color:#000; background:#FFF; line-height:20px; padding:10px; } ul li ul, ul li:hover ul li ul { display: none; } ul li:hover ul { display:block; position:absolute; top:auto; left:0; height:auto; } ul li:hover ul li a { display:block; text-align:center; border-bottom:1px solid #FFF; } ul li:hover ul li:hover ul { display:block; position:absolute; left:124px; top:0; }
HTML:
<div class="center"> <ul id="menu"> <li><a href="#floorclosers">Floor Closers</a> <ul> <li><a href="#p-floorclosers">P-Floor Closers</a></li> <li><a href="#bp-floorclosers">BP-Floor Closers</a></li> <li><a href="#a-floorclosers">A-Floor Closers</a></li> <li><a href="#f-floorclosers">F-Floor Closers</a></li> <!--<li><a href="#h-floorclosers">H-Floor Closers</a></li>--> <!--<li><a href="#slimline-floorclosers">Slimline-Floor Closers</a></li>--> </ul> </li> <li><a href="#overheadconceledclosers">Over Head Concealed Closers</a> <ul> <li><a href="#p-overheadconceledclosers">P-Over Head Concealed Closers</a></li> <li><a href="#bp-overheadconceledclosers">BP-Over Head Concealed Closers</a></li> <li><a href="#a-overheadconceledclosers">A-Over Head Concealed Closers</a></li> <li><a href="#f-overheadconceledclosers">F-Over Head Concealed Closers</a></li> <li><a href="#h-overheadconceledclosers">H-Over Head Concealed Closers</a></li> </ul> </li> <li><a href="#sidelites">Side Lites</a> </li> </ul> </div> Please Help!!!
February 12, 2014 at 7:40 am #162690Paulie_D
MemberCould you please put that code dump into Codepen…it makes it much easier to help you.
The basic answer is, however, to NOT use floats but use
inline-block
ordisplay:table-cell
on theli
..with suitable additional properties.February 12, 2014 at 7:47 am #162692vpatterson
ParticipantI am sorry for my ignorance but very new to this site what is codepen?
February 12, 2014 at 7:56 am #162694Paulie_D
MemberCodepen.io is like jsfiddle.net.
A place where you can input your HTML, CSS & JS and have it run in a live environment without needing a site of your own.
The ‘Pen’ you create can be shared (as a link) and we can take copies, fork it and tweak it to get what you might need.
Like this: http://codepen.io/Paulie-D/pen/22c4ca602bda363099133ded6bca2294
February 12, 2014 at 8:03 am #162695vpatterson
ParticipantWell my company has network restrictions and I cant view this page any further than inputting the code and saving. So I hope this worked http://codepen.io/vpatterson/pen/fxjEF.
February 12, 2014 at 9:00 am #162698vpatterson
ParticipantI am not sure if anyone will be looking to this thread for help. But I have found the solution to my problem. I changed my width to 455px and inserted a height of 32px and set my margins to auto. thank you for who tried to help.
February 12, 2014 at 9:00 am #162699Paulie_D
MemberOk…I removed the margins you had on the
.center
div (not sure what they were doing) so it’s now 100% wide.If you want to restrict the width on the div change it to a
max-width
to keep it responsive (if that’s what you want)Then I remove the floats from the
li
and changed them to'display:inline-block
and got thishttp://codepen.io/Paulie-D/pen/GliIK
Is that more like what you were after?
It can easily be tweaked if not.
As an alternative, here’s the
display:table
(on theul
) anddisplay:table-cell
on theli
optionFebruary 12, 2014 at 9:03 am #162700vpatterson
ParticipantI got it but thank you anyway now it just seems like it was a simple problem
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.