Форум программистов
 

Восстановите пароль или Зарегистрируйтесь на форуме, о проблемах и с заказом рекламы пишите сюда - alarforum@yandex.ru, проверяйте папку спам!

Вернуться   Форум программистов > Web программирование > HTML и CSS
Регистрация

Восстановить пароль
Повторная активизация e-mail

Купить рекламу на форуме - 42 тыс руб за месяц

Ответ
 
Опции темы Поиск в этой теме
Старый 03.04.2014, 11:26   #1
izhtownfun
Пользователь
 
Регистрация: 03.04.2014
Сообщений: 26
Восклицание проблема с выравниванием текста div

доброе время суток.
нашел в интернете симпатичное "меню"(если так можно назвать) на css
Код:
<!DOCTYPE html>
<html>
<head>	
	<meta charset="utf-8">
	<title>Меню</title>
	<link rel="stylesheet" href="reset.css">
	<link rel="stylesheet" href="style.css">	
	<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
	<!--[if (gte IE 6)&(lte IE 8)]> 
		<script src="selectivizr.js"></script>
	<![endif]-->
	<style>
		#about{
		    color: #999;
		    text-align: center;
		    font: 0.9em Arial, Helvetica;
		}

		#about a{
		    color: #777;
		}		
	</style>
</head>

<body>
<div>
  <ul class="menus">
    <li tabindex="1">
      <span class="title"></span> 
      <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Suspendisse interdum dictum <a href='vk.com'>scelerisque</a>. Morbi eu euismod lorem.</div>
    </li>
    <li tabindex="1">
      <span class="title"></span> 
      <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Suspendisse interdum dictum scelerisque. Morbi eu euismod lorem.</div>
    </li>
    <li tabindex="1">
      <span class="title"></span> 
      <div class="content">Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Suspendisse interdum dictum scelerisque. Morbi eu euismod lorem.</div>
    </li>    
  </ul>
</div>

	<script>
	  (function(){
	  
		// Добавялем кнопку закрытия каждому блоку
		$('.menus .content').append('<span class="close">x</span>');		
		// Выводим окно
		function showContent(elem){
			hideContent();
			elem.find('.content').addClass('expanded');
			elem.addClass('cover');	
		}
		// Сбрасываем все
		function hideContent(){
			$('.menus .content').removeClass('expanded');
			$('.menus li').removeClass('cover');		
		}
		
		// Когда элемент li нажат, выводим окно с его содержанием и позиционируем поверх всего
		$('.menus li').click(function() {
			showContent($(this));
		});		
		// Содержание будет также выводиться с помощью нажатия клавиши ENTER
		$('.menus li').keypress(function(e) {
			if (e.keyCode == 13) { 
				showContent($(this));
			}
		});

		// Когда нажат верхний правый элемент, сбрасываем все
		$('.menus .close').click(function(e) {
			e.stopPropagation();
			hideContent();
		});		
		// Также сброс происходит по нахатию клавиши ESC
		$(document).keyup(function(e) {
			if (e.keyCode == 27) { 
			  hideContent();
			}
		});
		
	  })();
	</script>
</body>
</html>
в коде немного грязи осталось, т.к. изначально было 9 "пунктов меню", но не суть.

по моей задумке в каждом пункте меню - картинка с надписью,описывающая этот самый пункт. при нажатии меню разворачивается, показывая немного текста и ссылки.
проблема же заключается в том, что текст и ссылки залазят на надпись меню, т.к. текст идет с самого верха. каким образом можно выравнять текст в открывающемся меню, чтобы он был снизу слева. ну или хотя бы по середине.
заранее благодарю за помощь.

Последний раз редактировалось izhtownfun; 03.04.2014 в 11:28.
izhtownfun вне форума Ответить с цитированием
Старый 03.04.2014, 11:27   #2
izhtownfun
Пользователь
 
Регистрация: 03.04.2014
Сообщений: 26
По умолчанию

а вот CSS (в предыдущее сообщение не влезло)

Код:
.menus{
  width: 620px;
  margin: 100px auto; padding: 15px;	  
  list-style: none;
  counter-reset: li;
  background: #eee;
  -moz-box-shadow: 0 1px 2px rgba(0,0,0,.1) inset;
  -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.1) inset;
  box-shadow: 0 1px 2px rgba(0,0,0,.1) inset;
  -moz-border-radius: 10px;
  -webkit-border-radius: 10px;
  border-radius: 10px;
}

.menus:before,
.menus:after {
  content: "";
  display: table;
}

.menus:after {
  clear: both;
}

.menus {
  zoom:1;
}

/* -------------------------------- */        

.menus li {
  position: relative;
  float: left;
  cursor: pointer;
  height: 180px; width: 200px;
  margin: 10px 0 0 10px;
  color: #000;
} 

.menus li:hover, .menus li:focus{
  background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(255,255,255,.2)), to(rgba(255,255,255,0)));
  background-image: -webkit-linear-gradient(top, rgba(255,255,255,.2), rgba(255,255,255,0));
  background-image: -moz-linear-gradient(top, rgba(255,255,255,.2), rgba(255,255,255,0));
  background-image: -ms-linear-gradient(top, rgba(255,255,255,.2), rgba(255,255,255,0));
  background-image: -o-linear-gradient(top, rgba(255,255,255,.2), rgba(255,255,255,0));
  background-image: linear-gradient(top, rgba(255,255,255,.2), rgba(255,255,255,0));
}

.menus .cover{
  z-index: 2;
}

.menus .cover:focus{
  outline: 0;
}

/* -------------------------------- */

.menus li::after{
  content: counter(li);
  counter-increment: li;
  font: italic bold 10px serif, georgia;
  position: absolute;
  color: rgba(255,255,255,.1);
  opacity: 0;
  -webkit-transition: all .2s ease-out;
  -moz-transition: all .2s ease-out;
  -ms-transition: all .2s ease-out; 
  -o-transition: all .2s ease-out;  
  transition: all .2s ease-out;    
}      

.menus li:hover::after, .menus li:focus::after{
  font-size: 100px;
  opacity: 1; 
}

.menus .cover::after{
  z-index: -1;
}

/* -------------------------------- */       

.menus li:nth-child(1),
.menus li:nth-child(2),
.menus li:nth-child(3){
  margin-top: 0;
}

.menus li:nth-child(1),
.menus li:nth-child(4),
.menus li:nth-child(7){
  margin-left: 0;      
}

/* -------------------------------- */       

.menus li:nth-child(1),
.menus li:nth-child(1) .content,
.menus li:nth-child(1) .close{
  background-color: #2c618f;
  background-image: url(menus1.png);
  background-position: left;
}         

.menus li:nth-child(2),
.menus li:nth-child(2) .content,
.menus li:nth-child(2) .close{
  background-color: #91ab31;
  background-image: url(menus2.png);  
}   

.menus li:nth-child(3),
.menus li:nth-child(3) .content,
.menus li:nth-child(3) .close{
  background-color: #714a28;
  background-image: url(menus3.png);  
}

/* -------------------------------- */

.menus .content{
  opacity: 0; display: none\9;
  overflow: hidden;
  font: 12px Arial, Helvetica;
  position: absolute;
  height: 120px; width: 200px; /* В идеале: height: 100%; width: 100%; , но будет работать только в FF */
  -webkit-transition: all .3s ease-out;
  -moz-transition: all .3s ease-out;
  -ms-transition: all .3s ease-out; 
  -o-transition: all .3s ease-out;  
  transition: all .3s ease-out;      
}  

.menus .expanded{
  opacity: .95; display: block\9;
  overflow: visible;
  padding: 40px;
  height: 100px; width: 540px; /* Покрываем всю область */
}

.menus li:nth-child(3n) .content{ /* 3,6,9 */
  right: 0;
}

.menus li:nth-child(3n-1) .expanded{ /* 2,5,8 */
  left: 50%;
  margin-left: -310px;
}

.menus li:nth-child(7) .content, /* 7,8,9 */
.menus li:nth-child(8) .content,
.menus li:nth-child(9) .content{
  bottom: 0;
}                      

.menus li:nth-child(4) .expanded, /* 4,5,6 */
.menus li:nth-child(5) .expanded,
.menus li:nth-child(6) .expanded{
  margin-top: -190px;
  top: 50%;
} 

/* -------------------------------- */    

.menus .title{
  position: absolute;
  height: 100%; width: 100%;
  text-align: center;
  font: italic bold 1em/120px 'trebuchet MS', Arial, helvetica;
  opacity: .2;
}

.menus li:hover .title{
  opacity: .7;
}    

/* -------------------------------- */

.menus .close {
  display: none;
  border: 5px solid #fff;
  color: #fff;
  cursor: pointer;
  height: 40px; width: 40px;
  font: bold 20px/40px arial, helvetica;
  position: absolute;
  text-align: center;
  top: -20px; right: -20px;
  -moz-border-radius: 40px;
  -webkit-border-radius: 40px;
  border-radius: 40px;      
}

.menus .cover .close{
  display: block;
}
izhtownfun вне форума Ответить с цитированием
Старый 03.04.2014, 14:36   #3
izhtownfun
Пользователь
 
Регистрация: 03.04.2014
Сообщений: 26
По умолчанию

все, разобрался, создал внутри еще один див меньший по размеру и к нему уже другие параметры применил
izhtownfun вне форума Ответить с цитированием
Ответ


Купить рекламу на форуме - 42 тыс руб за месяц

Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
modx. проблема с выравниванием текста lir1c WordPress и другие CMS 0 17.10.2013 17:16
Проблема с выравниванием Masafi HTML и CSS 5 09.01.2013 14:52
Проблема с выравниванием при масштабировании wois HTML и CSS 5 06.12.2011 08:45
Проблема с выводом текста в DIV vlad.md HTML и CSS 6 20.11.2011 19:33
макрос вставка текста между тегами <div> </div> nur91m Microsoft Office Word 2 19.10.2011 22:16