I'm currently working on a pure CSS color palette that needs to be a link. I've created this palette by using an unordered list, which I then wrapped in a <a> tag. I have a suspicion that this is not very semantic though. What would be the correct way to achieve this?
HTML
<div class="color-palette">
Modern Feminine
<a href="#">
<ul class="color-chips group">
<li class="grey">#999999</li>
<li class="slate">#666666</li>
<li class="lilac">#99878D</li>
<li class="blush">#7E4A5C</li>
<li class="plum">#372129</li>
</ul><!--.color-chips group-->
</a>
</div><!--.color-palette-->
CSS
.color-palette {
width: 280px;
margin: 0 auto;
padding: 0;
}
ul.color-chips {
margin: 0 auto;
padding: 0;
}
ul.color-chips li {
float: left;
margin: 0;
}
ul.color-chips li {
float: left;
width: 55px;
height: 55px;
text-indent: -9999px;
}
You can't put a list inside an anchor.
You need to make each of the individual items in the list a seperate link.
<ul class="color-chips group">
<li class="grey">#999999</li>
<li class="slate">#666666</li>
<li class="lilac">#99878D</li>
<li class="blush">#7E4A5C</li>
<li class="plum">#372129</li>
</ul><!--.color-chips group-->
If you don't need links because you're not actually linking to anything (i.e. you're performing on-the-page operations) simply remove the anchors all together. You don't need them when attaching your Javascript onclick events.
<ul class="color-chips group">
<li class="grey">#999999</li>
<li class="slate">#666666</li>
<li class="lilac">#99878D</li>
<li class="blush">#7E4A5C</li>
<li class="plum">#372129</li>
</ul>
What would you like to do after your click? Do you use javascript event when click is fired?
Since you're already handling clicks with JS, I assume the anchor is purely cosmetic. In that case you can use CSS:
.color-chips:hover {
cursor:pointer;
}
Related
HTML fixed footer with vertically scrolling content (standard stuff I hope, overflow:auto etc.).
When vertically scrolling through elements via right-swipe VoiceOver gesture as soon as VoiceOver focus hits the elements at the bottom of the visible view the VoiceOver focus moves through elements correctly but the scrollbar only scrolls half the element height hence the VoiceOver focus moves below the visible area.
EDIT Updated snippet, in previous one height of container was less that 50%, updated for clarity to show that the height doesn't matter.
Thanks in advance.
.scrollContainer {
position: absolute;
overflow: auto;
top: 0;
width: 100%;
bottom: 100px;
}
.rightData {
float: right;
padding-right: 10px;
}
.stepData {
padding: 0px;
list-style-type: none;
margin-top: 0;
margin-bottom: 0;
}
.stepData > li {
height: 42px;
border-top: 1px solid black;
padding: 12px 20px;
font-size: 1.25em;
}
#footer {
position: absolute;
height: 100px;
width: 100%;
bottom: 0;
background-color: cyan;
}
<div style="height:500px;">
<div id="container" class="scrollContainer">
<ul class="stepData" style="padding:0px;">
<li role="button" aria-label="date">06/01<span class="rightData" aria-label="steps">1001</span></li>
<li role="button" aria-label="date">06/02<span class="rightData" aria-label="steps">1002</span></li>
<li role="button">06/03<span class="rightData">1003</span></li>
<li role="button">06/04<span class="rightData">1003</span></li>
<li role="button">06/05<span class="rightData">1005</span></li>
<li role="button">06/06<span class="rightData">1006</span></li>
<li role="button">06/07<span class="rightData">1007</span></li>
<li role="button">06/08<span class="rightData">1008</span></li>
<li role="button">06/09<span class="rightData">1009</span></li>
<li role="button">06/10<span class="rightData">1010</span></li>
<li role="button">06/11<span class="rightData">1011</span></li>
<li role="button">06/12<span class="rightData">1012</span></li>
<li role="button">06/13<span class="rightData">1013</span></li>
<li role="button">06/14<span class="rightData">1014</span></li>
<li role="button">06/15<span class="rightData">1015</span></li>
<li role="button">06/16<span class="rightData">1016</span></li>
<li role="button">06/17<span class="rightData">1017</span></li>
<li role="button">06/18<span class="rightData">1018</span></li>
<li role="button">06/19<span class="rightData">1019</span></li>
<li role="button">06/20<span class="rightData">1020</span></li>
<li role="button">06/21<span class="rightData">1021</span></li>
<li role="button">06/22<span class="rightData">1022</span></li>
<li role="button">06/23<span class="rightData">1023</span></li>
<li role="button">06/24<span class="rightData">1023</span></li>
<li role="button">06/25<span class="rightData">1025</span></li>
<li role="button">06/26<span class="rightData">1026</span></li>
<li role="button">06/27<span class="rightData">1027</span></li>
<li role="button">06/28<span class="rightData">1028</span></li>
<li role="button">06/29<span class="rightData">1029</span></li>
<li role="button">06/30<span class="rightData">1030</span></li>
<li role="button">07/01<span class="rightData">1031</span></li>
<li role="button">07/02<span class="rightData">1032</span></li>
<li role="button">07/03<span class="rightData">1033</span></li>
<li role="button">07/04<span class="rightData">1034</span></li>
<li role="button">07/05<span class="rightData">1035</span></li>
<li role="button">07/06<span class="rightData">1036</span></li>
<li role="button">07/07<span class="rightData">1037</span></li>
<li role="button">07/08<span class="rightData">1038</span></li>
<li role="button">07/09<span class="rightData">1039</span></li>
</ul>
</div>
<div id="footer">
<p>
footer
</p>
</div>
</div>
Not sure whether this helps but you can try setting the VoiceOver focus manually. If you're lucky, this might also scroll to the correct position.
If that does not work, you could try to use Element.scrollIntoView() which should work in the latest versions of Safari Mobile. But I am not sure whether that also plays nicely with VoiceOver.
The trick to making pages scrollable in Voiceover is to keep main content areas in the normal document flow using position:relative, not absolute. (I think overflow: hidden and max-height: 100% on the body element causes problems too, but I need to do more research.) The nav can use fixed positioning and slide in next to the rest of the content. One limitation is that a menu that also overflows the page height probably won’t scroll in Voiceover, as it will suffer from the original positioning bug.
I have my horizontal navigation, and one of the links has a dropdown menu. I'm having trouble removing my the vertical scrollbar from my horizontal navigation. Because of this, you have to scroll down to see the dropdown. If I remove the scrollbar, you cannot see the dropdown menu. I've tried to set a height, tried different overflow settings, even z-index.. nothing has worked.
https://jsfiddle.net/83qgv1nb/
nav.mainNav {
margin: 0;
padding: 0;
width: 75%;
float: right;
display: block;
overflow: auto;
}
ul.menu {
margin: 0;
padding: 0;
height: 100px;
overflow-y: visible;
}
li.item {
margin: 0;
padding: 0;
height: 100px;
width: 16%;
position: relative;
float: left;
list-style-type: none;
}
a.navLink {
margin: 0;
padding: 0;
display: block;
text-align: center;
line-height: 95px;
text-decoration: none;
font-weight: bold;
}
<nav class="mainNav">
<ul class="menu">
<li class="item">
About
<ul class="sub_menu">
<li class="sub_item">
Location
</li>
<li class="sub_item">
History
</li>
<li class="sub_item">
Community Involvement
</li>
<li class="sub_item">
Leadership
</li>
</ul>
</li>
<li class="item">Services</li>
<li class="item">Projects</li>
<li class="item">Blank</li>
<li class="item">Blank</li>
<li class="item">Contact</li>
</ul>
</nav>
1st you should remove your
.mainNav{
...
overflow:auto"
...
}
This is clearly what makes your menu "scrollable"!
Here, your "submenu" is always visible... If you're looking for a way to show/hide your submenu then You should use "bootstrap", it's easy and it has lots of examples of dropdown menus.
If you want to make it yourself, then :
Try to identify your dropdown menu item, give it a class or something that allows you to check if user clicks on a dropdown or not.
Then, on "click", do an action that show/hides the next list element. (jquery's got a "toggle()" function made for this kind of job)
On document load, set all your dropdown menus with display:none. To hide them. Then, on click on them, just use toggle() on them, or add them an attribute that makes them visible, such as an "active" class.
here is a short example on how you could handle this with jQuery : https://jsfiddle.net/83qgv1nb/21/
(this is just an example, there are lots of other examples or way to do this, I'm not pretending that my example here is the best way!)
if you do not use jQuery, then just check this link : Using Javascript to hide and show drop down menu and text field
update :
This is what you try to do with css i guess... : https://jsfiddle.net/83qgv1nb/27/
The following is a screen capture of the issue that i'm faced with. The drop down menu is supposed to appear under the second menu item in the top menu.
The HTML is,
<nav class="nav">
<ul>
<li class="menu-item">Hi Alexander!</li>
<li class="menu-item"><a>My Account</a>
<div class="my-sub-menu">
<ul class="sub-list">
<li class="list-item"><a>History</a></li>
<li class="list-item"><a>Personal Details</a></li>
<li class="list-item"><a>Preferences</a></li>
<li class="list-item"><a>Bonuses</a></li>
<li class="list-item"><a>Wishlist</a></li>
<li class="list-item"><a>Newsletter</a></li>
<li class="list-item"><a>Invite Friends</a></li>
<li class="list-item"><a>FAQ</a></li>
<li class="list-item"><a>Sign out</a></li>
</ul>
</div>
</li>
<li class="menu-item"><a>Contact Us</a></li>
<li class="menu-item"><a>Chat</a></li>
<li class="menu-item"><a>Chat</a></li>
</ul>
</nav>
The CSS is as follows,
.nav {
margin-top: 2px;
position: relative;
float: right;
}
.nav > ul {
padding: 0;
margin: 0;
}
.menu-item{
list-style: none;
float: left;
}
.menu-item .my-sub-menu {
visibility: hidden;
position: absolute;
padding: 0;
margin: 0;
}
.menu-item:hover .my-sub-menu {
visibility: visible;
}
.list-item {
list-style: none;
}
I need the sub menu to appear under the second item in the top menu. This is only in firefox and IE but chrome renders it perfectly. I cant figure out what the issue is. Is there at least e fix that i could use for these two browsers? or another alternative to get around this issue.
Tahnk you in advance.
If you add position:relative to .menu-item it will make the absolute positioning work from the list item itself. The only draw back is if you are using a percentage based width on your drop down it will take the width of the parent li as 100% so a pixel width may have to be specified.
try doing
.sub-list{
padding:0px !important;
}
and if by second menu u want it to come under contact us
then change the position of the div
<div class="my-sub-menu">
<ul class="sub-list">
<li class="list-item"><a>History</a></li>
<li class="list-item"><a>Personal Details</a></li>
<li class="list-item"><a>Preferences</a></li>
<li class="list-item"><a>Bonuses</a></li>
<li class="list-item"><a>Wishlist</a></li>
<li class="list-item"><a>Newsletter</a></li>
<li class="list-item"><a>Invite Friends</a></li>
<li class="list-item"><a>FAQ</a></li>
<li class="list-item"><a>Sign out</a></li>
</ul>
</div>
into the next li element ie cntact us
kind of a fiddle
fiddle ex
I am trying to get my bullet-point.png images to show up on the right side of each of my navigation/li menu options.
I did it with some in-valid HTML5, but would prefer to do it properly. Here is my screenshot from before so it explains what I am after. (I previously just added in multiple strings on each menu item). I think it's better to have each menu item assigned to a class with a background-image defined instead.
The HTML/CSS below displays the navigation like the screenshot but without any of the bullet-point images. Any idea why?
HTML
<nav class="nav">
<div class="span12">
<ul>
<li class="bullet-point">HOME</li>
<li class="bullet-point">PROJECTS</li>
<li class="bullet-point">CASE STUDIES</li>
<li class="bullet-point">PROFILE</li>
<li class="bullet-point">NEWS & EVENTS</li>
<li class="bullet-point">LOCATION</li>
<li class="bullet-point">CONTACT</li>
</ul>
</div>
</nav>
CSS
.bullet-point {
margin-top: -5px;
margin-right: 10px;
background: url('img/bullet-point.png');
}
Fiddle: http://jsfiddle.net/avinvarghese/eemTZ/
Css:
.bullet-point {
margin-top: -5px;
margin-right: 10px;
list-style:none;
float:left;
}
.bullet-point:after {
content:" • ";
}
.bullet-point:last-child:after {
content: "";
}
It should be
ul {
list-style-image: url('img/bullet-point.png');
}
Background images do not apply here.
I'm trying to build a css drop down menu.
I have a div #category_list which is hidden and I want to display it once user hover over #category_drop list element. I tried
#category_drop:hover #category_list {visibility: visible;}
But this doesn't work. Can you please suggest any solution?
My full HTML
<div id="headbar-wrap">
<p id="back-top"><span></span></p>
<div id="head-bar">
<h1>website</h1>
<ul class="main-menu">
<li><a class="st_nav_menu" href="index.php">Home</a></li>
<li id="category_drop"><a class="st_nav_menu" href="#">Categories</a></li>
<li><a class="st_nav_menu" href="top.php">Top</a></li>
<li><a class="st_nav_menu" href="anti-top.php">Anti Top</a></li>
<li class="st_add_button">Add Story</li>
</ul>
<ul class="main-2-menu">
<li><a><span style="color: red; font-weight: bold; font-size: 16px; line-height: 44px; padding: 0 10px 0 10px;">Website is under construction.</span></a></li>
</ul>
<!-- this is a hidden drop down menu -->
<div id="category_list" style="height: 400px; width: 500px; background: #000; position: absolute; z-index: 999; top: 45px; visibility: hidden;"></div>
</div>
</div>
js Fiddle of a current situation http://jsfiddle.net/nzC65/2/
Please note that :hover doesn't work for non-anchor (a tag) on older browsers.
Secondly in your code, category_list is not a child of category_drop and hence your CSS will not actually match any elements.
Check this fiddle for a working implementation: http://jsfiddle.net/YT8YR/