Answer the question
In order to leave comments, you need to log in
How to make a block appear when clicking on a link using CSS?
I need the block( .map ) to appear when hovering over the link( #map_sh ). Tried to do it with code like this:
#map_sh:focus+.map {
display: block;
}
function showHide(element_id) {
if (document.getElementById(element_id)) {
var obj = document.getElementById(element_id);
if (obj.style.display != "block") {
obj.style.display = "block";
} else obj.style.display = "none";
}
}
Answer the question
In order to leave comments, you need to log in
#map_sh:hover + .map {
display: block;
}
it is not possible to do this with simple css, because in this case the structure does not allow html code
, use the jQuery library and the click function (if you want the .map block to appear when you click on the #map_sh link)
$('#map_sh'). click(function() {
$('.map').toggleClass('active');
})
or use this construct (if you want the .map block to appear when hovering over the #map_sh link)
$( "#map_sh " ).hover(
function() {
$( '.map').addClass('active');
}, function() {
$( '.map').removeClass('active');
}
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question