我正在处理一个层次结构页面并且无法滚动它,它应该从屏幕水平滚动以显示所有部门,但它只是创建新部门低于其他部门并且看起来有点奇怪(正如我的屏幕截图中的测试部门7所见,它应该是在屏幕上创建测试部门7并允许滚动。我已经包含了用于创建层次结构的css以及截图来解释我的意思。整个层次结构基于http://astuteo.com/slickmap/这里的内容。我是新鲜的想法,对此的任何新想法将不胜感激,谢谢。可能会有一些我可以使用的jquery,它会以#primaryNav为目标吗?
----在.ascx文件中-----
我在这里使用knockoutjs来创建层次结构
<div class="row-fluid" data-bind="if: MapViewVisible, visible: Items().length > 0" style="display: none;">
<div class="span12" data-bind="visible: MapViewVisible">
<ul id="primaryNav" class="col10" data-bind="template: { name: 'root-template', foreach: Hierarchy}">
</ul>
</div>
</div>
---- CSS ------
#primaryNav li {
width:25%;
}
#primaryNav li ul li {
width:100% !important;
}
#primaryNav.col1 li { width:99.9%; }
#primaryNav.col2 li { width:50.0%; }
#primaryNav.col3 li { width:33.3%; }
#primaryNav.col4 li { width:25.0%; }
#primaryNav.col5 li { width:20.0%; }
#primaryNav.col6 li { width:16.6%; }
#primaryNav.col7 li { width:14.2%; }
#primaryNav.col8 li { width:12.5%; }
#primaryNav.col9 li { width:11.1%; }
#primaryNav.col10 li { width:12.5%; }
/* ------------------------------------------------------------
General Styles
------------------------------------------------------------ */
body {
/*background: white;
color: black;
padding: 40px;
font-family: Gotham, Helvetica, Arial, sans-serif;
font-size: 12px;
line-height: 1;*/
}
.sitemap {
margin: 0 0 40px 0;
float: left;
width: 100%;
}
h1 {
font-weight: bold;
text-transform: uppercase;
font-size: 20px;
margin: 0 0 5px 0;
}
h2 {
font-family: "Arial", Verdana, sans-serif;
font-size: 10px;
color: #777777;
margin: 0 0 20px 0;
}
a {
text-decoration: none;
}
ol, ul {
list-style: none;
}
/* ------------------------------------------------------------
Site Map Styles
------------------------------------------------------------ */
/* -------- Top Level --------- */
#primaryNav {
margin: 0;
float: left;
width: 200%; /*tried this and overflow but didnt seem to work*/
overflow-x:auto;
}
#primaryNav #home {
display: block;
float: none;
background: #ffffff url('/_layouts/images/barium/lines/L1-left.png') center bottom no-repeat;
position: relative;
z-index: 2;
padding: 10px 0 30px 0;
}
#primaryNav li {
float: left;
background: url('/_layouts/images/barium/lines/L1-center.png') center top no-repeat;
padding: 30px 0;
margin-top: -30px;
}
#primaryNav li a {
margin: 0 20px 0 0;
padding: 10px 0;
display: block;
font-size: 14px;
font-weight: bold;
text-align: center;
color: black;
background: #c3eafb url('/_layouts/images/barium/lines/white-highlight.png') top left repeat-x;
border: 2px solid #b5d9ea;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
-webkit-box-shadow: rgba(0,0,0,0.5) 2px 2px 2px;
-moz-box-shadow: rgba(0,0,0,0.5) 2px 2px 2px; /* FF 3.5+ */
}
#primaryNav li a:hover {
background-color: #e2f4fd;
border-color: #97bdcf;
}
#primaryNav li:last-child {
background: url('/_layouts/images/barium/lines/L1-right.png') center top no-repeat;
}
#primaryNav a:link:before,
#primaryNav a:visited:before {
/*content: " "attr(href)" ";*/
display: block;
text-transform: uppercase;
font-size: 10px;
margin-bottom: 5px;
word-wrap: break-word;
}
#primaryNav li a:link:before,
#primaryNav li a:visited:before {
color: #78a9c0;
}
/* -------- Second Level --------- */
#primaryNav li li {
width: 100%;
clear: left;
margin-top: 0;
padding: 10px 0 0 0;
background: url('/_layouts/images/barium/lines/vertical-line.png') center bottom repeat-y;
}
#primaryNav li li a {
background-color: #cee3ac;
border-color: #b8da83;
}
#primaryNav li li a:hover {
border-color: #94b75f;
background-color: #e7f1d7;
}
#primaryNav li li:first-child {
padding-top: 30px;
}
#primaryNav li li:last-child {
background: url('/_layouts/images/barium/lines/vertical-line.png') center bottom repeat-y;
}
#primaryNav li li a:link:before,
#primaryNav li li a:visited:before {
color: #8faf5c;
}
/* -------- Third Level --------- */
#primaryNav li li ul {
margin: 10px 0 0 0;
width: 100%;
float: right;
padding: 9px 0 10px 0;
background: #ffffff url('/_layouts/images/barium/lines/L3-ul-top.png') center top no-repeat;
}
#primaryNav li li li {
background: url('/_layouts/images/barium/lines/L3-center.png') left center no-repeat;
padding: 5px 0;
}
#primaryNav li li li a {
background-color: #fff7aa;
border-color: #e3ca4b;
font-size: 12px;
padding: 5px 0;
width: 80%;
float: right;
}
#primaryNav li li li a:hover {
background-color: #fffce5;
border-color: #d1b62c;
}
#primaryNav li li li:first-child {
padding: 15px 0 5px 0;
background: url('/_layouts/images/barium/lines/L3-li-top.png') left center no-repeat;
}
#primaryNav li li li:last-child {
background: url('/_layouts/images/barium/lines/L3-bottom.png') left center no-repeat;
}
#primaryNav li li li a:link:before,
#primaryNav li li li a:visited:before {
color: #ccae14;
font-size: 9px;
}
li a p, li a .nofontweight
{
font-weight:400;
}
答案 0 :(得分:0)
主UL容器外的类(行 - 流体)具有宽度约束。如果你使用overflow:auto
设置.row_fluid,那应该可以解决问题。
然而,如果没有看到大量的工作样本,那就是我现在可以评估的全部内容。
jsFiddle.net是发布和测试示例代码的好地方。