September 30, 201214 yr I'm attempting to revise a site to make it responsive and I'm having some trouble with some of the layout. On this page, the nested lists below the image slider are not displaying correctly, including not being centred. And on this page the #products div is also not being centred. I'm not sure what is going wrong - any suggestions? Thanks as always.
October 1, 201214 yr The first thing to say is that my computer hasn't got font-family: LiebeErikaRegular; so I see Arial in very large size, so I can't really check your page. See if you can use @font-face http://www.wickham43...3.php#font-face kit from fontsquirrel. Edit, I see that you have used @font-face but I obviously didn't download all the files. However, you have .markets container with width: 95%; margin: auto; and that is centering. Inside you have .marketName { float: left; width:100%; } which is floated left and the li tags start from there, so they aren't filling the 100% width or centering inside .markets. You can do it by sizing each li tag with a class and different % width totalling 100% or use a code shown in item 4 here http://www.wickham43...opdownmenus.php where all the li tags have different unsized widths but they center in the container. Edited October 1, 201214 yr by Wickham
October 1, 201214 yr Author http://www.wickham43...opdownmenus.php Thanks - this was useful. However the last list item is jumping down to the next line. I've tried adding additional list items and they all display nicely except the last one, whether I have 3 items or 6 items the last one moves down. I've also tried playing around with li:last-child, but that didn't seem to make an impact. Any ideas? I've uploaded the amendments from the tutorial you pointed to (very helpful in explaining floats).
October 1, 201214 yr If the end li tag drops down, that's a sure sign that there isn't enough width in one of the containers. It happens with my tutorial if you make the page width narrower, so one answer is to add a min-width into the top level parent container.
October 1, 201214 yr I would do something like this: ul{ text-align:center; min-height:161px; } li{ display:inline-block; } The min-height is the height of the bigger bloc, so all of them stack well when they drop down. You can also this dynamically with js, in case something will change in the future. edit: The first thing to say is that my computer hasn't got font-family: LiebeErikaRegular Thanks for this!! My girlfriend's name is Erika and she is German. I love the font, so I will buy it as a present for her Edited October 1, 201214 yr by ocorreiododiogo
October 1, 201214 yr Author I'm not sure I understand this - its only the last li that moves down. If I have 2 list items, then the 2nd drops down. If I have 5 list items 4 display on the same line and the 5th moves down. The container stretches and shrinks to accommodte the list items but pushes the last one down, even if i stretch the window size very wide. I'm not sure what setting min-width will do.
October 1, 201214 yr Oh, sorry, I didn't understand that you wanted the last one to go always down. In that case, add this last declaration to my previous css ul{ text-align:center; } li{ display:inline-block; } li:last-child{ display:block; margin:auto } http://jsfiddle.net/zXQXU/3/ EDIT: margin:auto was missing Edited October 1, 201214 yr by ocorreiododiogo
October 1, 201214 yr Author I didn't understand that you wanted the last one to go always down. Thanks for having a look, but I DONT want any of the list items to move to a new line. I want all of them on the same line and there is enough space. I dont understand why the last one is not staying on the same line as all the others. This page illustrates the problem.
October 1, 201214 yr Dammit! I guess I got somehow fouled by this: I've also tried playing around with li:last-child You must be changing things, so I'm not sure how to read your markup. One thing I noticed, is that you have the <ul> inside some divs. There is no point on doing that, since the <ul> can be targeted by itself, and maybe this is making it more confusing.
October 1, 201214 yr Author One thing I noticed, is that you have the <ul> inside some divs. I added in the extra divs as Wickham suggested this item 4 herehttp://www.wickham43...opdownmenus.php where all the li tags have different unsized widths but they center in the container It does have the effect of making the container responsive to varying window sizes which is what I want. I can't for the life of me understand why the ****ing last list item insists on jumping down. This is like a basic horizontal dropdown menu right? Its the same on all the major browsers, so I know its something I'm doing wrong. Thanks again for having a look.
October 1, 201214 yr Well, honestly I don't understand all that extra markup. I get the feeling that it drops down because it's respecting the size of the div#markets. I managed to fix it in chrome tools by using my technique from above. The problem is that everything in aligning in the bottom but I don't know why... have to leave, but can track this later
October 1, 201214 yr Author Thanks for your efforts. In the first image where all four are on the same line, it doesn't look as if the list is centered. I will continue to search for a solution, hopefully someone here can help.
October 2, 201214 yr On this page http://www.nuttyladyltd.co.uk/indexV2.html, you could just remove all the margins etc from #products and just have: #products { clear: both; display: block; text-align: center; } It works for me, but I'm not sure it's the correct way of doing it. Don't know about the second page though. Lyndsey.
October 2, 201214 yr On the about.html page, using the code you had two days ago, I can see that .marketName > li { float: left; width:20%;} has 20% for each li tag but you have only four so the total is 80% starting from the left, so it looks left-aligned. You could edit it to 25% but because the text in each top level item is different, with short text for Barnes food fair, it still looks slightly left-aligned. I used my other suggestion and added a class to each li tag with a different % width #marketTitle { font-family: LiebeErikaRegular; margin:20px 0 0 0; color:#FF9; font-size:3.2em; text-align:center; } .markets { width:95%; margin:auto; color:#FF9; font-size:2.6em; line-height:2em; font-family: LiebeErikaRegular; } .marketName { background: purple; float: left; width:100%; margin: 0; padding: 0; } .marketName > li { float: left; /*width:20%; deleted, see separate classes*/ } .marketDates > li { /*float:left; */ font-size:.8em; line-height:1.2em; } .marketDates li:first-child { margin-top:-0.3em; } .width1 { width: 25%; background: pink; } .width2 { width: 35%; background: skyblue; } .width3 { width: 25%; background: lime; } .width4 { width: 15%; background: yellow; } and markup <div class="markets"> <ul class="marketName"> <li class="width1"><a href="http://www.kewvillagemarket.org/">Kew Community Market</a> <ul class="marketDates"> <li>7th October</li> <li>4th November</li> <li>2nd December</li> </ul> </li> <li class="width2"><a href="http://www.landmarkartscentre.org/whats- on/other-events.html">Contemporary Craft & Gourmet Food Fair</a> <ul class="marketDates"> <li>16-18th November</li> </ul> </li> <li class="width3"><a href="">Latymer Christmas Fair</a> <ul class="marketDates"> <li>24th November</li> </ul> </li> <li class="width4"><a href="">Barnes Food Fair</a></li> </ul> </div><!-- end markets div --> I also deleted float:left; in .marketDates > li so that all sub-level items form a vertical list. I also added margin: 0; padding: 0; to .marketname to clear a left space. It improves the look of the links a lot. Edited October 2, 201214 yr by Wickham
October 2, 201214 yr Author Thanks for the suggestions. I am out all day but will try these suggestions tonight.
October 5, 201214 yr Author Thanks Wickham for your suggestions, they were very helpful. I've ended up cheating a bit because I want to keep the design flexible and your first solution allows that. I've set .marketName > li:last-child{ color:#000 } Thanks Lindsey for your suggestion - the problem is that it then aligns the images along the top which looks weird. I'm not sure where to go from here but will continue to search for an rwd solution.
Create an account or sign in to comment