首页 \ 问答 \ 居中我的导航(Centering My Nav)

居中我的导航(Centering My Nav)

我需要在这个网站( http://beautra.weebly.com/ )中心导航,任何想法? 这是代码,我尝试使用inspect元素工具,但我无法解决它。 代码似乎很简单,但我不知道如何使用jsfiddle。 任何帮助也将不胜感激。 谢谢,

/* Navigation --------------------------------------------------------------------------------*/

#topnav {
    clear: both;
    text-align:center;
    background: url(nav-left.png) no-repeat;
    padding-left: 8px;
    width: 971px;
}

#nav-right {
    background: url(nav-right.png) right top no-repeat;
    padding-right: 10px;
}

#nav-inner {
    background: url(nav-inner.png) repeat-x;
    padding: 2px 5px 3px;
}

#topnav ul {
    list-style: none;
    float: none;
    background: url(nav-sep.jpg) no-repeat left center;
}

#topnav ul li {
    list-style: none;
    float: left;
    background: url(nav-sep.jpg) no-repeat right center;
    padding-right: 2px;
}

#topnav a {
    float: left;
    text-align:center;
    display: block;
    color: #989899;
    text-decoration: none;
    padding: 19px 38px;
    border: 0;
    outline: 0;
    list-style-type: none;
    font-size: .9em;
}

#topnav li#active a,
#topnav a:hover {
    transition: 0.5s; 
    -moz-transition: 0.5s; 
    -webkit-transition: 0.5s; 
    -o-transition: 0.5s; 
    color: #ed53ae;
    background: #090909 url(nav-active.png);
    border: 0;
}

I need to center the nav in this website ( http://beautra.weebly.com/ ), any ideas? Here's the code, I tried playing with the inspect element tool but I couldn't work it out. The code seems simple enough to work out but I don't know how to work with jsfiddle. Any help with that too would be appreciated. Thanks,

/* Navigation --------------------------------------------------------------------------------*/

#topnav {
    clear: both;
    text-align:center;
    background: url(nav-left.png) no-repeat;
    padding-left: 8px;
    width: 971px;
}

#nav-right {
    background: url(nav-right.png) right top no-repeat;
    padding-right: 10px;
}

#nav-inner {
    background: url(nav-inner.png) repeat-x;
    padding: 2px 5px 3px;
}

#topnav ul {
    list-style: none;
    float: none;
    background: url(nav-sep.jpg) no-repeat left center;
}

#topnav ul li {
    list-style: none;
    float: left;
    background: url(nav-sep.jpg) no-repeat right center;
    padding-right: 2px;
}

#topnav a {
    float: left;
    text-align:center;
    display: block;
    color: #989899;
    text-decoration: none;
    padding: 19px 38px;
    border: 0;
    outline: 0;
    list-style-type: none;
    font-size: .9em;
}

#topnav li#active a,
#topnav a:hover {
    transition: 0.5s; 
    -moz-transition: 0.5s; 
    -webkit-transition: 0.5s; 
    -o-transition: 0.5s; 
    color: #ed53ae;
    background: #090909 url(nav-active.png);
    border: 0;
}

原文:https://stackoverflow.com/questions/22291485
更新时间:2022-11-27 08:11

最满意答案

当您查找到顶点的路径而不是顶点本身时,应将顶点标记为未访问。

想象一下,在遍历之后,您没有将顶点标记为未访问,并且某些搜索遍历图形的一部分并且确实找到了有问题的顶点的路径。 在某些时候,搜索用完了边缘来探索和回溯它的步骤到某个早期点,从那里继续。

如果要搜索的顶点有一条路径通过同样位于找到的第一条路径上的顶点,则算法将找不到第二条路径,因为它会将公共顶点视为已访问过的路径。

另一方面,如果您只寻找一条路径(或只是存在一个顶点,即根本没有路径),那么您可以跳过将节点标记为“在出路时未访问”。


The vertex should be marked as not visited when you are looking for paths to a vertex instead of the vertex itself.

Imagine you don't mark vertexes as not visited after traversing, and that some search traverses a part of the graph and does find a path to the vertex in question. At some point the search runs out of edges to explore and retraces its steps to some earlier point, continuing from there.

If there is another path to the vertex being searched for that passes through a vertex that is also on the first path found, the algorithm would not find the second path because it would consider the common vertex as already visited.

On the other hand, if you are looking for just one path (or for just the presence of a vertex, i.e. no paths at all) then you can skip marking nodes as not visited "on your way out".

相关问答

更多
  • DFS: list nodes_to_visit = {root}; while( nodes_to_visit isn't empty ) { currentnode = nodes_to_visit.take_first(); nodes_to_visit.prepend( currentnode.children ); //do something } BFS: list nodes_to_visit = {root}; while( nodes_to_visit isn't empty ...
  • 我认为只使用显式堆栈作为当前路径和递归更简单: def search(start_state, neighbors, goal): path = [start_state] class PathFound(RuntimeError): pass def rsearch(x): if goal(x): raise PathFound for y in neighbors(x): path ...
  • 维基百科上描述的算法看起来很容易使用显式堆栈进行非递归。 从那开始(包括在这里作为参考,如果维基百科改变): Input: Graph G = (V, E) index = 0 // DFS node number counter S = empty // An empty stack of node for all v in V do if ...
  • 首先,这个问题在codeReview或计算机科学中会更好。 不知道哪个,但我倾向于使用计算机科学来解决复杂性问题。 然而: 答案1: 是的,它确实是深度优先,因为在开始使用正确的子树之前,您会到达左子树中的叶子。 答案2: 由于您只对每个节点进行一次评估,因此您的时间复杂度为O(n) ,其中n是树中节点的数量。 你的空间复杂度应该是O(d) ,其中d是树的深度,因为在计算Solution(right)时你必须记住Solution(left) Solution(right) First of all, thi ...
  • 好的,这是。 您不仅需要DFS,还需要存储找到的路径。 您为findPath建议的方法签名将不起作用。 它的path参数是一个列表,它会在遍历时存储所有节点,因为即使它是一个递归算法,我们也不会在将它传递给下一个findPath调用之前完全复制列表,坦率地说,我们不应该这样做以提高性能并减少内存消耗。 我能想到的最简单方法就是让每个单元都指向它的父级。 父单元是将单元作为邻居发现的单元。 我们必须为findPath使用以下签名 List findPath(Maze currentMaze, Ce ...
  • maxDepth(node)的代码如下所示: 如果node不为null : 在node的左侧子node上运行相同的算法maxDepth 。 让这个答案是x 。 在node的右侧子node上运行相同的算法maxDepth 。 让这个答案是y 。 计算Math.max(x, y) + 1 ,并返回该值作为此函数调用的答案。 否则, node为null ,然后返回0 。 这意味着,当我们试图在非空节点上计算maxDepth(node)时,我们首先计算两个node的子node上的maxDepth() ,然后让这两个 ...
  • 我可以看到这种行为的主要原因是每次递归调用时重新初始化state (和parent )数组。 每个遍历只需要初始化一次。 常见的方法是将这些数组添加到函数参数列表中,使用None初始化它们,并在第一次调用时替换列表: def dfs_tree(graph, start, parent=None, state=None): a_list = graph.adjacency_list if parent is None: parent = [None]*len(a_list) ...
  • path变量是函数的本地变量。 每个递归调用都有自己的堆栈帧 - 它独立于其他调用)。 这意味着当下一个电话开始时,一切都是全新的。 The path variable is local to the function. Every recursion call has its own stack frame - it is independent from the other calls). That means when the next call starts, then everything is ...
  • 当您查找到顶点的路径而不是顶点本身时,应将顶点标记为未访问。 想象一下,在遍历之后,您没有将顶点标记为未访问,并且某些搜索遍历图形的一部分并且确实找到了有问题的顶点的路径。 在某些时候,搜索用完了边缘来探索和回溯它的步骤到某个早期点,从那里继续。 如果要搜索的顶点有另一条路径通过同样位于找到的第一条路径上的顶点,则算法将找不到第二条路径,因为它会将公共顶点视为已访问过的路径。 另一方面,如果您只寻找一条路径(或只是存在一个顶点,即根本没有路径),那么您可以跳过将节点标记为“在出路时未访问”。 The ver ...
  • 问题出在你的dfs()函数中,你没有检查节点是否已被访问过,你在if条件中检查节点是否为0 - if key == 0: ,那么它会继续递归对于第0个节点,即使它已被访问过。 并且由于第0个节点的这种无限递归,当达到最大递归限制时,它会弹出错误 - RuntimeError: maximum recursion depth exceeded 。 您应该从图形中检查key的值,而不是图形本身。 并且您也没有在任何地方使用邻接列表。 您应该根据邻接列表循环,而不是访问的字典。 示例 - graphAL2 = { ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)