I have a page with a list of anchors that is displayed in a vertical list. Upon clicking a certain one I am opening a partial view with another list of li items, but specifically changed to be inline. Only problem is that when the partial view is displayed the main view list of items changes to inline as well. Is there anyway around this?
Main page portion;
<ul>
<li>
<a href="" onclick="return OpenAdminPage('user');" >User Maintenance</a>
</li>
<li>
<a href="" onclick="return OpenAdminPage('role');" >Role Maintenance</a>
</li>
<li>
<a href="" onclick="return OpenAdminPage('type');" >Item Type Maintenance</a>
</li>
<li>
<a href="" onclick="return OpenAdminPage('tran');" >Transaction Type Maintenance</a>
</li>
<li>
<a href="" onclick="return OpenAdminPage('inven');" >Inventory Control Maintenance</a>
</li>
</ul>
partial view:
<ul>
#if (Model != null)
{
#Html.HiddenFor(x=>x.InventoryRoleCode)
for (var rolcnt = 0; rolcnt < Model.Roles.Count(); rolcnt++)
{
<li style="color:black;font-size:x-small">
#Html.DisplayTextFor(x => x.Roles[rolcnt].ItemTypeCode)
#Html.HiddenFor(x => x.Roles[rolcnt].ItemTypeCode)
</li>
<li>
#Html.CheckBoxForWithTitle(x=>x.Roles[rolcnt].Included)
</li>
}
}
</ul>
<style>
ul li
{
display: inline-block;
}
</style>
Related
I have a multi-level ul list like below.
<ul>
<li>
</li>
<li>
<a href="/">
</a>
<ul>
<li>
<ul>
<li>
</li>
<li>
<ul>
<li>
</li>
<li>
</li>
</ul>
</li>
</ul>
</li>
<li>
</li>
</li>
</li>
</ul>
There could be more levels inserted.
So I want every ul > li > a will have a padding-left+10 of it's parent a tag.
you can use forloop for adding css for all the anchor tags at once.
add class in anchor tag for get element by class
var lis = document.getElementByClass("link").getElementsByTagName("li");
after this you can implement css using javascript:
var sheet = window.document.styleSheets[0];
sheet.insertRule('a { padding-left: 50px; }', sheet.cssRules.length);
The treeview example of the WAI-ARIA Authoring Practices shows how to have a tree with some items being expandable parent nodes, and some being hyperlinks:
<ul role="tree" aria-label="Foods">
<li role="treeitem" aria-expanded="true">
<span> Fruits </span>
<ul role="group">
<li role="none"> <a role="treeitem" href="/orange"> Oranges </a> </li>
<li role="none"> <a role="treeitem" href="/pineapple"> Pineapple </a> </li>
</ul>
</li>
</ul>
However, what if I want to have a "Fruits" page too, and have a treeitem that is both a parent node and a hyperlink?
(For keyboard navigation, the pattern of Right Arrow/Left Arrow opening/closing the parent node, and Enter following the hyperlink would be used. This resembles the interaction of a combobox with a tree popup.
For mouse interaction, the current pattern would be kept: having a clickable icon (aria-hidden) indicating expanded state, which opens/closes the node, and the text of the link itself, which follows the link.)
For example:
<ul role="tree" aria-label="Foods">
<li role="none">
<a role="treeitem" aria-expanded="true" href="/fruits">
<span> Fruits </span>
<ul role="group">
<li role="none"> <a role="treeitem" href="/orange"> Oranges </a> </li>
<li role="none"> <a role="treeitem" href="/pineapple"> Pineapple </a> </li>
</ul>
</a>
</li>
</ul>
This, while technically correct, violates the HTML spec, which disallows <a> tags being nested within other <a> tags.
After much searching, I found this answer, which is about a different topic and only hints at my solution.
To have the <a> element be the treeitem, while simultaneously "containing" other <a> elements nested within groups, the aria-owns attribute can be used.
Like this, the requirement that
Each parent node contains or owns an element with role group.
is satisfied, while at the same time following the HTML spec.
<ul role="tree" aria-label="Foods">
<li role="none">
<a role="treeitem" aria-expanded="true" aria-owns="fruit-group" href="/fruits">
<span> Fruits </span>
</a>
<ul role="group" id="fruit-group">
<li role="none"> <a role="treeitem" href="/orange"> Oranges </a> </li>
<li role="none"> <a role="treeitem" href="/pineapple"> Pineapple </a> </li>
</ul>
</li>
</ul>
This is not exactly what you are looking for but I thought I would share it for anyone that is looking for something similar that accomplishes the same thing at least from the end user's perspective.
The following code has been modified from w3school's Tree View Example to have clickable arrows and parent link items besides them.
Original code: https://www.w3schools.com/howto/howto_js_treeview.asp
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
ul, #myUL {
list-style-type: none;
}
#myUL {
margin: 0;
padding: 0;
}
.caret {
cursor: pointer;
-webkit-user-select: none; /* Safari 3.1+ */
-moz-user-select: none; /* Firefox 2+ */
-ms-user-select: none; /* IE 10+ */
user-select: none;
}
.caret::before {
content: "\25B6";
color: black;
display: inline-block;
margin-right: 6px;
}
.caret-down::before {
-ms-transform: rotate(90deg); /* IE 9 */
-webkit-transform: rotate(90deg); /* Safari */'
transform: rotate(90deg);
}
.nested {
display: none;
}
.active {
display: block;
}
</style>
</head>
<body>
<h2>Tree View</h2>
<p>A tree view represents a hierarchical view of information, where each item can have a number of subitems.</p>
<p>Click on the arrow(s) to open or close the tree branches.</p>
<ul id="myUL">
<li><span class="caret">Beverages</span>
<ul class="nested">
<li>Water</li>
<li><span class="caret">Juice</span>
<ul class="nested">
<li>Orange Juice</li>
<li>Apple Juice</li>
</ul>
</li> <!-- End of caret Tea -->
<li><span class="caret">Tea</span>
<ul class="nested">
<li>Black Tea</li>
<li>White Tea</li>
<li><span class="caret"></span>Green Tea
<ul class="nested">
<li>Sencha</li>
<li>Gyokuro</li>
<li>Matcha</li>
<li>Pi Lo Chun</li>
</ul>
</li>
</ul>
</li> <!-- End of caret Tea -->
</ul> <!-- End of nested -->
</li> <!-- End of caret Beverage -->
</ul> <!-- End of myUL -->
<script>
var toggler = document.getElementsByClassName("caret");
var i;
for (i = 0; i < toggler.length; i++) {
toggler[i].addEventListener("click", function() {
this.parentElement.querySelector(".nested").classList.toggle("active");
this.classList.toggle("caret-down");
});
}
</script>
</body>
</html>
I have to limit the items to 5 items but the first and last item should still display on top and bottom of the list.
I tried setting the height to fixed size of 7 items(5 items plus the first and last item) and inserting scroll bar for overflow but the problem is, the last item which should be on the bottom part is hidden.
Here is my HTML code:
<li class="dropdown-submenu">
<a href="javascript:;"
data-toggle="dropdown">
<img th:src="#{/resources/images/completion/design/add_geomechanics.png}" width="15" height="15" alt="...">
<span>Add Geomechanics</span>
</a>
<ul class="dropdown-menu" style="left: -245px">
<li v-if="mseConfig.length > 0">
<a href="javascript:;">
Select Geomechanics Configuration
</a>
</li>
<li v-for="(config, index) in mseConfig" v-bind:class="config.isSelected ? 'applied-mse-config' : ''" style="position: relative;">
<a href="javascript:;" v-bind:class="config.isSelected ? 'mse-config-design-anchor-white-color' : 'mse-config-design-anchor-black-color'" id="mse-config-design-anchor" v-on:click="configureMSE(config)">
- {{config.title}}
<i class="icon-trash mse-config-design-trash"
v-on:click.stop="deleteMSEConfig(config, index)">
</i>
</a>
</li>
<li style="border-top: 1px solid #d1e0ea;">
<a href="javascript:;" data-toggle="modal" data-target="#mdlSEMCreatePallete">
Create Geomechanics Configuration
</a>
</li>
</ul>
</li>
I want the list to be like on the photo with only the middle items are scrollable and only shows 5 items.
Try by making the scrollbars invisible. You can still scroll though.
.dropdown-menu::-webkit-scrollbar {
display: none;
}
I have a drop-down menu in a Shopify site I'm creating.
On desktop, the main li is clickable to a link, as well as opening the sub-menu items when hovered.
On mobile, the main li ONLY opens the sub-menu "drawer", but can't be selected as a link on its own.
How can I make it selectable and open the drawer on mobile?
li a {
display: block;
padding: 7px 10px !important;
text-align: left !important;
}
<li class="site-nav--has-dropdown site-nav--active" aria-haspopup="true">
<a href="/" class="site-nav__link">
Home
<span class="icon icon-arrow-down" aria-hidden="true"></span>
</a>
<ul class="site-nav__dropdown">
<div>
<li>
ABOUT
</li>
<li>
PLANS & PRICING
</li>
<li>
POLICIES
</li>
<li>
CENTER
</li>
<li>
BACK
</li>
<li>
FAQ
</li>
<li>
OUR TEACHERS
</li>
</div>
<span class="arrow"> </span>
</ul>
</li>
Include the main li link as the first item in the sub-menu (in addition to the link in the main menu).
Display it on mobile devices.
Hide it with display: none on desktop devices.
Im trying to change the nav item in my ASP.Net MVC 4 project. I have found some examples but they dont work with the way the menu in need( See code):
<nav>
<ul>
<li>
<a href="/StartMenu/Index" class="current" title="Dashboard">
<i class="icon-map-marker"></i>
Dashboard
</a>
</li>
<li>
<a href="/StartMenu/Forms" title="Forms Stuff">
<i class="icon-edit"></i>
Forms Stuff
</a>
</li>
If all you're trying to do is make sure the last link that was clicked has class="current" you can do this
$("a").click(function() {
$("a").removeClass("current");
$(this).addClass("current");
})