css在PHP内部的html中处于活动状态回声在左击时不会保留 [英] css active on html inside php echo doesn't stay when click is left
问题描述
下面是一个php文件中的回声,它也使用sql来获取数据。答案在默认情况下使用CSS显示隐藏:无。但是当显示答案被点击时,显示。我的问题是,当点击被留下时,答案不会保持显示。就像当我点击它显示,但不离开点击时不留。如何让它留下来?
echo< div class ='span3 tiny'>
< div class ='pricing-table-header-tiny'>
< h2> 。 $ row ['Question']。 < / h2>
< / div>
< a id ='s'>显示答案< / a>
< div class ='dq'>
< div class ='pricing-table-features'>
< p> 。 $ row ['Answer']。 < / p>
< / div>
< div class ='Dass'>
< p id ='Dassp'>回答:。 $ row ['Doctor']。 < p>
< / div>
< / div>
< / div>; // $ row ['index']这里的索引是一个字段名称
.dq {display:none;}#s:active〜.dq {display:block;}#s {padding:5px 15px;背景:#ddd; cursor:pointer;}
<使用纯css来实现这一点
看看它是如何完成的!
你必须使 a
标记一个 link
以使这项工作在':active
状态。
< a href =id =s>
并为写入样式:focus
state还有一个缺点就是当你点击元素外部时, active
状态将会消失。在这种情况下,您必须使用 jquery
。
#s: active〜.dq,#s:focus〜.dq {
display:block;
}
.dq {display:none;} a {文字修饰:无; } #s:active〜.dq,#s:focus〜.dq {display:block;}#s {padding:5px 15px;背景:#ddd; cursor:pointer;}
< div class ='span3微小'> < div class ='pricing-table-header-tiny'> < h2>问题:问题是什么?< / h2> < / DIV> < a id ='s'href =#>显示答案< / a> < div class ='dq'> < div class ='pricing-table-features'> < p>你好,这是答案< / p> < / DIV> < div class ='Dass'> < p id ='Dassp'>通过回答:Kim< p> < / DIV> < / div>< / div>
below is an echo in a php file which also uses sql to get data. answer is hidden by default using css display: none. but when the show answer is clicked it shows. my problem is that the answer doesnt stay shown when the click is left. like when i click it shows but doesnt stay when i leave the click. how do i make it stay?
echo "<div class='span3 tiny'>
<div class='pricing-table-header-tiny'>
<h2>" . $row['Question'] . "</h2>
</div>
<a id='s'>Show answer</a>
<div class='dq'>
<div class='pricing-table-features'>
<p>" . $row['Answer'] . "</p>
</div>
<div class='Dass'>
<p id='Dassp'>Answered by:" . $row['Doctor'] . "<p>
</div>
</div>
</div>"; //$row['index'] the index here is a field name
.dq {
display: none;
}
#s:active~ .dq {
display:block;
}
#s {
padding: 5px 15px;
background: #ddd;
cursor: pointer;
}
Use pure css to achieve this
See how its done !!
You have to make the a
tag a link
to make this work on ':active
state.
<a href="" id="s">
and write the style for :focus
state also
The only drawback is that when you click outside the element, the active
state will gone. In that case, you have to use jquery
.
#s:active~ .dq, #s:focus~ .dq{
display: block;
}
.dq {
display: none;
}
a{
text-decoration: none;
}
#s:active~ .dq, #s:focus~ .dq{
display: block;
}
#s {
padding: 5px 15px;
background: #ddd;
cursor: pointer;
}
<div class='span3 tiny'>
<div class='pricing-table-header-tiny'>
<h2>" Question : whats is the question ?"</h2>
</div>
<a id='s' href="#">Show answer</a>
<div class='dq'>
<div class='pricing-table-features'>
<p>" Hi this is the answer "</p>
</div>
<div class='Dass'>
<p id='Dassp'>Answered by: "Kim"
<p>
</div>
</div>
</div>
这篇关于css在PHP内部的html中处于活动状态回声在左击时不会保留的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!