displaying labels horizontally instead of vertically in thymeleaf [duplicate] - spring

So, I have attempted to create a horizontal list for use on a new website I am designing. I have attempted a number of the suggestions found online already such as setting 'float' to left and such - yet none of these have worked when it comes to fixing the problem.
ul#menuItems {
background: none;
height: 50px;
width: 100px;
margin: 0;
padding: 0;
}
ul#menuItems li {
display: inline;
list-style: none;
margin-left: auto;
margin-right: auto;
top: 0px;
height: 50px;
}
ul#menuItems li a {
font-family: Arial, Helvetica, sans-serif;
text-decoration: none;
font-weight: bolder;
color: #000;
height: 50px;
width: auto;
display: block;
text-align: center;
line-height: 50px;
}
<ul id="menuItems">
<li>
Home
</li>
<li>
DJ Profiles
</li>
</ul>
Currently I am unsure of what is causing this issue, how would I go about and resolve it?

Updated Answer
I've noticed a lot of people are using this answer so I decided to update it a little bit. No longer including support for now-unsupported browsers.
ul > li {
display: inline-block;
/* You can also add some margins here to make it look prettier */
}
<ul>
<li> some item
</li>
<li> another item
</li>
</ul>

This fiddle shows how
http://jsfiddle.net/9th7X/
ul, li {
display:inline
}
Great references on lists and css here:
http://alistapart.com/article/taminglists/

I guess the simple solution i found is below
ul{
display:flex;
}

A much better way is to use inline-block, because you don't need to use clear:both at the end of your list anymore.
Try this:
<ul>
<li>
some item
</li>
<li>
another item
</li>
</ul>
CSS:
ul > li{
display:inline-block;
}
Have a look at it here : http://jsfiddle.net/shahverdy/4N6Ap/

You could also use inline blocks to avoid floating elements
<ul>
<li>
some item
</li>
<li>
another item
</li>
</ul>
and then style as:
li{
/* with fix for IE */
display:inline;
display:inline-block;
zoom:1;
/*
additional styles to make it look nice
*/
}
that way you wont need to float anything, eliminating the need for clearfixes

Here you can find a working example, with some more suggestions about dynamic resizing of the list.
I've used display:inline-block and a percentage padding so that the parent list can dynamically change size:
display:inline-block;
padding:10px 1%;
width: 30%
plus two more rules to remove padding for the first and last items.
ul#menuItems li:first-child{padding-left:0;}
ul#menuItems li:last-child{padding-right:0;}

strong tex
ul {
list-style: none;
display: flex;
justify-content: space-around;
}
<ul>
<li>bla</li>
<li>blabla</li>
<li>blablabla</li>
</ul>

Related

Alternatives to Javascript-powered drop down lists for accessibility purposes

Most drop down lists in websites' main menus are powered by Javascript, which usually displays some div element containing the list on click or hover. But non Javascript users just can't see the drop down list!
The only alternative I can think of is to display the drop down list as a HTML select element, but nobody does that. Is there a better solution out there?
Non-JavaScript menus are surprisingly common and are often times just as clean and can be more efficient than their JavaScript counterparts. You can use JavaScript but it's important to have graceful degradation if you want your menu to be accessible and functional for all users.
There are many examples of these online but the basic premise is to have a normal navigation menu (using UL and LI elements), and use CSS to change the look and appearance based on the user interaction (such as a hover).
Here is an example of a basic menu that will work without CSS or JavaScript and still be perfectly usable (some of the code taken from this answer: https://stackoverflow.com/a/12279190/937012)
<div class="wrapper">
<navigation role="navigation" class="primary-nav">
<ul role="menubar">
<li role="presentation">
<a role="menu-item" href="#" title="First Link">First Link</a>
</li>
<li role="presentation" class="sub-container"> <a role="menu-item" aria-haspopup="true" href="#" title="Second Link">Second Link</a>
<ul role="menu">
<li role="presentation"> <a role="menu-item" href="#" title="Sub Menu Item 1">Sub Item 1</a>
</li>
<li role="presentation"> <a role="menu-item" href="#" title="Sub Menu Item 2">Sub Item 2</a>
</li>
<li role="presentation"> <a role="menu-item" href="#" title="Sub Menu Item 3">Sub Item 3</a>
</li>
</ul>
</li>
<li role="presentation">
<a role="menu-item" href="#" title="Third Link">Third Link</a>
</li>
</ul>
</navigation>
</div>
As is, this will create a navigation menu (using some accessibility attributes) that is cross-browser and accessible. You can read more about accessibility best practices here: https://www.webaccessibility.com/best_practices.php
You can then apply whichever CSS you like to change the appearance and give the desired "drop-down" effect.
Here is some CSS for the above markup that produces a horizontal menu that features a sub-menu that appears below the second link when the mouse is moved over the second list item.
A {
text-decoration: none;
}
A:HOVER {
color: blue;
}
.wrapper {
width: 90%;
display: block;
}
.primary-nav {
display: block;
margin: 0px auto;
width: 100%;
padding: 0px;
}
.primary-nav UL {
background-color: #ababcd;
list-style-type: none;
margin-left: 0px;
padding-left: 0px;
text-indent: 0px;
}
.primary-nav > UL {
display: inline;
border: solid 1px #000000;
text-indent: 0px;
float: left;
height: 24px;
margin: 0px;
width: 100%;
list-style-type: none;
border-collapse: collapse;
}
.primary-nav LI {
max-width: 150px;
text-align: center;
}
.primary-nav > UL LI {
display: inline;
float: left;
padding: 0px 3px 0px 3px;
width: 32%;
line-height: 24px;
vertical-align: top;
margin-top: 0px;
text-align: center;
}
.primary-nav > UL LI UL {
display: none;
width: 100%;
}
.primary-nav > UL LI.sub-container:HOVER UL {
display: inline-block;
float: left;
margin-left: 0px;
clear: both;
border: inset 1px #898989;
box-shadow: 2px 2px 4px #000000;
}
.primary-nav > UL LI.sub-container:HOVER UL LI {
margin-top: 2px;
text-align: left;
clear: both;
width: 100%;
padding: 0px;
}
.primary-nav LI A:HOVER {
background-color: #cdcdef;
}
.primary-nav LI A {
display: block;
}
.primary-nav > UL LI.sub-container:HOVER UL LI A {
padding: 1px 3px;
margin: 0px 3px;
}
Here is a fiddle that stitches it all together: http://jsfiddle.net/xDaevax/osu7t9ty/

Styling multiple Foundation top-bars on a single page using SASS

I'm fairly new with SASS and I am wondering what is the best method for styling two different top-bars with different styles. What is the best practice using SASS? This question really applies to styling unique instances of anything from the built-in Foundation _settings.scss sheet. I have uncommented and made changes to certain items, and that works just fine as long as you want all instances of that component to be uniform, but when there are two uniquely styled versions of a single component, what should I do?
Agreed (…with your comment. Have an upvote!)
It's difficult to ferret out this kind of information, and that might really be because it's somewhat difficult to do. Not impossible, but not easy.
Global SASS/SCSS changes are just that: global. So while it's easy enough to change the .top-bar styles globally in _settings.scss, overriding individual element instances have proven tricky. Two .top-bars styled independently is tricky, and not to be accomplished using the global variable solutions.
The obvious, and purely CSS, way is to add an ID to each menu (I don't like IDs, but they fit the bill in this instance because of their near-indestructable specificity), and then you should be able to style each menu by simply making each rule specific enough to override the base .top-bar styles. I am in the process of doing this exact thing. So far, so good.
Here's my SCSS:
/* ==================
Page Head Styles
================== */
#utility-nav {
display: block;
width: 100%;
top:0;
width: 100%;
.top-bar.utility {
background-color: white;
margin: 0;
height: 29px;
a {
line-height: 29px;
height:29px;
padding: 0 auto;
color: #777;
background-color: white;
font-size: 14px;
&:hover {
color: #777;
background-color: #f2f2f2;
}
}
}
.top-bar-section {
max-width: 1170px;
margin: auto;
}
}
Which renders to this CSS:
#utility-nav {
display: block;
width: 100%;
top: 0;
width: 100%; }
#utility-nav .top-bar.utility {
background-color: white;
margin: 0;
height: 29px; }
#utility-nav .top-bar.utility a {
line-height: 29px;
height: 29px;
padding: 0 auto;
color: #777;
background-color: white;
font-size: 14px; }
#utility-nav .top-bar.utility a:hover {
color: #777;
background-color: #f2f2f2; }
#utility-nav .top-bar-section {
max-width: 1170px;
margin: auto; }
And here's the HTML it's attaching to:
<!--
Top Utility Menu
-->
<div id="utility-nav">
<nav class="top-bar utility show-for-large-up" data-topbar role="navigation">
<ul class="title-area">
<li class="name"></li>
<li class="toggle-topbar menu-icon"><span>Menu</span></li>
</ul>
<section class="top-bar-section">
<!-- Right Nav Section -->
<ul class="right">
<li>Careers</li>
<li>Contact Us</li>
<li>Blog</li>
<li>Sign In</li>
</ul>
</section>
</nav>
</div>
<!--
End Top Utility Menu
-->
So, that's ONE menu (the very top 'Utility' menu) overridden. Working on the second, #main navigation menu now.
In short, they don't make it easy. It would be nice if I could leverage SASS mixins to create a .top-bar-2 class and just have at it, but it can't be done at this time.

Center a horizontal menu with an image in the middle

I am trying to center my menu bar with my logo in the middle. right now everything is floating but it wont center to the middle of the page. Also when it is centered i need the background image that i placed on the left and right side of the logo to resize according to the width of the page - here is a link to how it looks live - Menu Test
on my website i still have the original menu I created where I placed the logo behind the menu bar and set a longer width so that the background would stretch but it won't auto adjust because of it.... Current Menu
I know my code is not perfect so please just bear with me
html
<div id="access">
<div class="menu-container">
<ul id="menu-left" class="menu">
<li class="menu-item">
Home
</li>
<li class="menu-item">
About
</li>
<li class="menu-item">
Services
</li>
</ul><!--END of menu-navigation-left-->
<ul id="menu-center">
<li class="menu-item">
<img src="images/logo.png" alt="Menu">
</li>
</ul> <!--close div center-->
<ul id="menu-right" class="menu">
<li class="menu-item">
Blog
</li>
<li class="menu-item">
Contact
</li>
<li class="menu-item">
Portfolio
</li>
</ul><!--END of menu-navigation-left-->
</div><!--END of menu-navigation-container-->
</div><!--END of access-->
css
header {
position:fixed;
}
#access {
width:100%;
overflow:hidden;
left:50%;
}
#access ul.menu{
display: inline-block;
}
#access ul {
}
#access ul a{
display:block;
}
#access ul#menu-left {
height:120px;
background-image:url(../images/menu.png);
}
#access ul#menu-center {
height:120px;
}
#access ul#menu-right {
height:120px;
background-image:url(../images/menu.png);
}
ul, li {
margin:0px;
padding:0px;
list-style:none;
float:left;
display:block;
}
#access a {
display: block;
font-size: 16px;
line-height: 15px;
padding: 13px 10px 12px 10px;
text-transform: titlecase;
text-decoration: none;
font:"Mc1regular", Arial, sans-serif;
}
a:link{
color:#fff;
}
a:visited{
color:#fff;
}
This should sort out your alignment issues.. just replace with your specs. I would just have one menu and centre it.
PLEASE NOTE, YOUR HEADER POSITION IS FIXED> position:relative would be better..
div.container {
width: 1160px;
margin: auto;
margin-top: -1;
margin-bottom: -1;
padding: 0;
padding-top: 10px;
background-color: #2d2d2d;
}
div.box {
margin: auto;
margin-top: 20px;
margin-bottom: 20px;
padding: 10px;
padding-bottom: 20px;
border: solid 1px #A29060;
background-color: #000;
overflow: hidden;
width: 940px;
}
div.top {
text-align: left;
margin: auto;
margin-left: 20px;
padding-top: 12px;
padding-bottom: 11px;
font-weight: normal;
font-size: 14px;
overflow: hidden;
width: 980px;
text-transform: uppercase;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li {
float: left;
padding-right: 20px;
}
a {
display: block;
color: #a29060;
text-decoration: none;
}
<div class="container">
<div class="box">
<div class="top">
<ul >
<li>Contact</li>
<li>Policies</li>
<li><img class="logo" src="images/logo.jpg" alt="logo" /></li>
<li>Policies</li>
</ul>
</div>
see this fiddle
http://jsfiddle.net/yvytty/RJ4Yp/
You can also have a look at this (it's not finished) but it has the basic layout sorted, menus etc
https://www.yve3.com/index.html
This is also a link to a great forum, HTML.net. They give you good opinions of your site and have a lot of expertise (just like here)
http://www.html.net/forums/

Is it possible to create a pure CSS submenu off a menu with a fixed height?

I have a vertical menu with some items that have a submenu that appears to the right of that item. This is mostly working fine, but the main menu might have a whole lot of items on it, so I want a max-height on it with a vertical scrollbar.
The problem is that if I set overflow: auto on the main menu, then the submenu no longer displays correctly because it can't overflow the main menu width.
Here's my code with an example at http://jsfiddle.net/FK8p6/. If you remove the overflow: auto from the .menu class, then you can see the submenu working correctly, but of course the main menu isn't displayed correctly any more, then.
HTML:
<ul class="menu">
<li>Menu 1</li>
<li>Menu 2</li>
<li>Menu 3</li>
<li>Menu 4</li>
<li>Menu 5</li>
<li>
Menu 6
<ul class="menu submenu">
<li>SubMenu 1</li>
<li>SubMenu 2</li>
<li>SubMenu 3</li>
</ul>
</li>
</ul>
CSS:
.menu
{
padding: 5px;
list-style-type: none;
background-color: #99f;
max-height: 80px;
width: 100px;
overflow: auto;
}
.menu li
{
border: #ddd 1px solid;
position: relative;
line-height: 24px;
cursor: default;
}
.menu li:hover
{
background-color: #d1e7ff;
}
.submenu
{
max-height: none;
background-color: #fff;
padding: 0;
position: absolute;
top: -1px;
left: 100%;
display: none;
}
.menu li:hover .submenu
{
display: block;
}
I know that I could pull the submenu outside of the main menu in the heirarchy, and then use javascript to position it. But then I lose the pure CSS menu and it would also no longer be semantic. I can live with that if I have to, but I'd like to find a better solution if possible.
Have you seen this tutorial? I don't think there's any problem with a fixed-height nav bar ...
http://www.devinrolsen.com/pure-css-horizontal-menu/
Oh darn - vertical menu? Possibly this won't help then.

How do I use inherit on min-width in CSS?

This seems really simple, but I can't get the syntax correct w/ the following scenario. I have some dropdown menus defined for the top of a screen. I want the list-items (each LI) to be AT LEAST as wide as its parent LI. It seems like an easy job for min-width and inherit, but I haven't been able to get it to work properly.
Right now, the "inherit" word just gets underlined in VS as if it's not recognized. The page will build/load fine, but it's clearly not reading the argument, as the LI controls aren't as wide as their parent LI's. Any help is appreciated.
Here is part of my HTML:
<ul id="javascriptDDM">
<li> MAIN OPTION 1
<ul>
<li> Choice 1 </li>
<li> Choice 2 </li>
<li> Choice 3 </li>
</ul>
</li>
<li> MAIN OPTION 2
<ul>
<li> Choice 1 </li>
<li> Choice 2 </li>
<li> Choice 3 </li>
</ul>
</li>
</ul>
... EDIT - here is ALL of the javascriptDDM CSS:
#javascriptDDM { width: auto; margin: 0; padding: 0 }
#javascriptDDM li { width: auto; float: left; list-style: none }
#javascriptDDM li a { display: block; background: #606668; padding: 5px 12px; text-decoration: none; border-right: 1px solid white; border-top: none; color: White; white-space: nowrap; background-position:left center; }
#javascriptDDM li a:hover { background: #999999; color: #FFFFFF; }
#javascriptDDM li ul { width: auto; margin: 0; padding: 0; position: absolute; visibility: hidden; z-index: 1000 }
#javascriptDDM li ul li { min-width: inherit; float: none; display: inline }
#javascriptDDM li ul li a{ color: #FFFFFF;background: #999999 }
#javascriptDDM li ul li a:hover { color: #000000; background: #FFFFFF}
Inherit will make the min-width property take the same "specified" value as the parent's min-width property. If you don't set min-width on a parent element, it won't have any value.
First of all, you should set your LI display mode to block. In this case, you will be at least able to control width of it.
WEFX
Only "block level" elements will inherit the width of their parents. The "a" element is not inherently a "block" level element.
So, to remedy this, you should either add a "display:block" to the "a" element, or, instead, place the min-width CSS on the li instead of the a.

Resources