<div class="tree-control">
<form>
<div class="input-append" style="margin-right: 10px;">
<input class="tree-search" type="text">
<button title="search" class="btn tree-search-btn" type="button"/>
</div>
<a href="">link</a>
some text
<a href="">link</a>
</form>
</div>我可以在不向添加任何标记的情况下隐藏一些文本吗?
我正试着这样做:
div.tree-control form {
display:none;
}
div.tree-control form > div:first-of-type {
display:block;
}但它会隐藏所有的形式。我怎么能把短信藏起来?
发布于 2017-09-11 08:56:01
您可以在这里使用可见性属性。
visibility属性与display属性不同,因为它允许隐藏父元素和可见子元素。
div.tree-control form {
visibility: hidden; /* hide the whole form */
}
div.tree-control form > div:first-of-type {
visibility: visible; /* make the first div in the form visible */
}
div.tree-control form {
visibility: hidden;
}
div.tree-control form > div:first-of-type {
visibility: visible;
}<div class="tree-control">
<form>
<div class="input-append" style="margin-right: 10px;">
<input class="tree-search" type="text">
<button title="search" class="btn tree-search-btn" type="button"/>
</div>
some text
</form>
</div>
发布于 2017-09-11 09:37:55
当不允许给标签时,没有禁用文本的方法。但对你来说总会有办法的。
更改与背景相同的文本颜色。希望这能帮到你。
<!DOCTYPE html>
<html>
<head>
<style>
div.tree-control form {
color:white;
}
div.tree-control form > div:first-of-type {
display:block;
}
</style>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
<div class="tree-control">
<form>
<div class="input-append" style="margin-right: 10px;">
<input class="tree-search" type="text">
<button title="search" class="btn tree-search-btn" type="button">
I am Button
</button>
</div>
some text
</form>
</div>发布于 2017-09-11 09:35:52
始终可以将文本添加为元素- <p>Some Text</p> <label>Some Text</label> <span>Some Text</span>。
分配和Id或类和简单的display: none;就行了。
form span{
display: none;
}<div class="tree-control">
<form>
<div class="input-append" style="margin-right: 10px;">
<input class="tree-search" type="text">
<button title="search" class="btn tree-search-btn" type="button"/>
</div>
<a href="">link</a>
<span>some text</span>
<a href="">link</a>
</form>
</div>
https://stackoverflow.com/questions/46151616
复制相似问题