@Shuboanator

Как сделать такой всплывающий текст?

https://www.choice.studio

На этом сайте при нажатии на меню и наведении на блок расскрывается текст и кнопка подробней, при этом центрирование не ломается. Подскажите как так сделать?
  • Вопрос задан
  • 5509 просмотров
Пригласить эксперта
Ответы на вопрос 2
dicem
@dicem
Вобще запилил без анимации https://jsfiddle.net/cm29kzbg/
Но я наткнулся на шикарный пример без js
Ответ написан
Да хотя бы вот так. https://codepen.io/kris-iris/pen/YJGJJL

А вот тебе с их сайта код поковырять
function first_open_menu(){
	// heigt menu_block_content
	if( menu_block_content_height_first_load == 1){

		// calculate size crop block content height
		menu_block_heading_height = menu_block_heading.getBoundingClientRect().height;
		menu_block_content_height_first_load = 0;

		// crop block content height
		for(i=0; i < menu_block_content.length; i++){
			menu_block_content_height[i] = menu_block_content[i].getBoundingClientRect().height;
			menu_block_content[i].style.height = menu_block_heading_height + 'px';
		}
	}
}


// hover effects menu block
menu_block_1.addEventListener('mouseover', menu_block_1_mouseover);
menu_block_1.addEventListener('mouseout', menu_block_1_mouseout);

menu_block_2.addEventListener('mouseover', menu_block_2_mouseover);
menu_block_2.addEventListener('mouseout', menu_block_2_mouseout);

menu_block_3.addEventListener('mouseover', menu_block_3_mouseover);
menu_block_3.addEventListener('mouseout', menu_block_3_mouseout);

menu_block_4.addEventListener('mouseover', menu_block_4_mouseover);
menu_block_4.addEventListener('mouseout', menu_block_4_mouseout);

function menu_block_1_mouseover(event){ if(stop_function_desktop == 0) return;  menu_block_content[0].style.height = menu_block_content_height[0] + 'px'; }
function menu_block_1_mouseout(event){ if(stop_function_desktop == 0) return; menu_block_content[0].style.height = menu_block_heading_height + 'px'; }

function menu_block_2_mouseover(event){ if(stop_function_desktop == 0) return; menu_block_content[1].style.height = menu_block_content_height[1] + 'px'; }
function menu_block_2_mouseout(event){ if(stop_function_desktop == 0) return; menu_block_content[1].style.height = menu_block_heading_height + 'px'; }

function menu_block_3_mouseover(event){ if(stop_function_desktop == 0) return; menu_block_content[2].style.height = menu_block_content_height[2] + 'px'; }
function menu_block_3_mouseout(event){ if(stop_function_desktop == 0) return; menu_block_content[2].style.height = menu_block_heading_height + 'px'; }

function menu_block_4_mouseover(event){ if(stop_function_desktop == 0) return; menu_block_content[3].style.height = menu_block_content_height[3] + 'px'; }
function menu_block_4_mouseout(event){ if(stop_function_desktop == 0) return; menu_block_content[3].style.height = menu_block_heading_height + 'px'; }
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы