I want the <div id="Feedback">
to appear when I hover over <p>Would you like to give feedback?</p>
. In other words, I want the <textarea>
and <p>How can we imporve the page?</p>
to have their display set to ‘block’ when I hover over that p element.
Heres what I tried:
<!DOCTYPE html>
<html>
<head>
<title>Sign up</title>
<link href="./account.css" rel="stylesheet">
</head>
<body>
<div id="entire-form">
<form action="form.html" method="GET">
<h1><b>Sign up =)</b></h1>
<div id="Feedback">
<p>Would you like to give feedback?</p>
<p>How can we imporve the page?</p>
<textarea name="improve" id="improve" rows="10" cols="70"></textarea>
</div>
</form>
</div>
</body>
</html>
textarea, #Feedback p{
display: none;
}
#Feedback p:nth-child(1) {
/*What this does is it looks in the div with the id Feedback and its p elements and selects the first child i.e. the p that comes first*/
display: block;
margin: 15px;
}
#Feedback p:nth-child(1):hover{
display: block;
}
2
Answers
You cannot achieve this without
JavaScript
. I have made some changes in your code regarding using correctHTML
elements and their order to achieve the desired functionality. I also updated yourCSS
part.textarea
will stay visible when user will hover the mouse on it or will type something in.I hope this will fix your problem. You can make further changes according to your desire.
If you want is " Show text area and ‘How can we improve the page?’ when you hover on ‘Would you like to give feedback?’then this will help you also you can achieve that with html and css only.
I have added class
someCss
&hiddenContent
. Add hiddenContent to div which you want to hide. Most css I have added is basic but this.someCss:hover ~ .hiddenContent{ display:block;}
is important as it addsdisplay: block
to hiddenContent when you hover onsomeCss
text. I have explained in stort as its simple.Below is working example.