我正在尝试创建常见问题解答,点击箭头我将显示答案。我正在使用此链接制作。
任何身体都可以建议我如何获得这些cls以便我可以修改以及如何放箭头。
Cls w3-btn w3-block w3-black w3-left-align
和w3-container w3-hide
我也想放箭头。
我的代码:
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<body>
<div class="w3-container">
<button onclick="myFunction('Demo1')" class="w3-btn w3-block w3-black w3-left-align">Open Section 1</button>
<div id="Demo1" class="w3-container w3-hide">
<h4>Section 1</h4>
<p>Some text..</p>
</div>
</div>
<script>
function myFunction(id) {
var x = document.getElementById(id);
if (x.className.indexOf("w3-show") == -1) {
x.className += " w3-show";
} else {
x.className = x.className.replace(" w3-show", "");
}
}
</script>
</body>
</html>
答案 0 :(得分:1)
也许有点简单,但我认为这就是你要找的东西?
#arrow {
float: right;
height: 20px;
width: 20px;
}
&#13;
<!DOCTYPE html>
<html>
<title>W3.CSS</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<body>
<div class="w3-container">
<button class="w3-btn w3-block w3-teal w3-left-align">Open Section 1<img id="arrow" src="http://golfergroups.com/img/arr.png" alt="arrow" onclick="myFunction('Demo1')" ></button>
<div id="Demo1" class="w3-container w3-hide">
<h4>Section 1</h4>
<p>Some text..</p>
</div>
<script>
function myFunction(id) {
var x = document.getElementById(id);
if (x.className.indexOf("w3-show") == -1) {
x.className += " w3-show";
} else {
x.className = x.className.replace(" w3-show", "");
}
}
</script>
</body>
</html>
&#13;
如果它不起作用或者这不是您正在寻找的内容,请与我们联系。
答案 1 :(得分:1)
希望这会对你有所帮助:)。
function myFunction(id) {
var x = document.getElementById(id);
if (x.className.indexOf("w3-show") == -1) {
x.className += " w3-show";
} else {
x.className = x.className.replace(" w3-show", "");
}
}
.w3-container,
.w3-panel {
padding: 0.01em 16px;
}
.w3-black,
.w3-hover-black:hover {
color: #fff!important;
background-color: #000!important;
}
.w3-block {
display: block;
width: 100%;
}
.w3-btn,
.w3-button {
border: none;
display: inline-block;
outline: 0;
padding: 8px 16px;
vertical-align: middle;
overflow: hidden;
text-decoration: none;
color: inherit;
background-color: inherit;
text-align: center;
cursor: pointer;
white-space: nowrap;
}
.w3-btn,
.w3-button {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.w3-block {
display: block;
width: 100%;
}
.w3-left-align {
text-align: left!important;
}
.w3-hide {
display: none;
}
.w3-show-block,
.w3-show {
display: block!important;
}
.w3-btn:hover {
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.FAQ1 {
position: relative;
}
.FAQ1 :before {
content: '';
width: 14px;
height: 14px;
position: absolute;
right: 10px;
top: 9px;
background-image: url(https://i.stack.imgur.com/3R9OU.png);
background-repeat: no-repeat;
background-size: cover;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="w3-container">
<div class="FAQ1">
<button onclick="myFunction('Demo1')" class="w3-btn w3-block w3-black w3-left-align">Open Section 1</button>
<div id="Demo1" class="w3-container w3-hide">
<h4>Section 1</h4>
<p>Some text..</p>
</div>
</div>
</div>