Показать сообщение отдельно
  #18 (permalink)  
Старый 07.03.2019, 12:58
Профессор
Отправить личное сообщение для Nexus Посмотреть профиль Найти все сообщения от Nexus
 
Регистрация: 04.12.2012
Сообщений: 3,733

Блондинка, почти
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title>transform</title>
<style type="text/css">
body { font: 14px normal Times, serif; }
div { border: 1px solid #ccc; padding: 5px; margin: 5px; }
a { text-decoration: none; color: #3c3vff; }
.xyz1 { color: #009900; }
.xyz2 { color: #11b311; }
.xyz3 { color: #28cc28; }
</style>
<script>
	document.addEventListener('DOMContentLoaded', ()=>{
		const uriWithoutParams=location.pathname.split(/[#|?]+/i).shift();
		const extension=uriWithoutParams.split('.').pop();
		const uriParts=uriWithoutParams.replace('.'+extension,'').split('/').filter(part=>part.length);
		const getClassName=index=>'xyz'+index;
		
		uriParts.forEach((uri,index)=>{
			uri='/'+uriParts.slice(0,++index).join('/')+'.'+extension;
			const className=getClassName(index);
			
			document.querySelectorAll(`a[href="${uri}"]`).forEach(node=>{
				node.classList.add(className);
			});
		});
	});
</script>
</head>
<body>
<div class="menu" id="menu1">
<a href="/html.html">HTML</a> 
<a href="/css.html">CSS</a> 
<a href="/js.html">JS</a> 
</div>
<div class="menu" id="menu2">
<a href="/css/css3.html">CSS3</a><br/>
<div>
<a href="/css/css3/transform.html">transform</a><br/>
<a href="/css/css3/transform-origin.html">transform-origin</a><br/>
<a href="/css/css3/transform-style.html">transform-style</a><br/>
</div>
</div>
</body>
</html>
Ответить с цитированием