[英]How do I get text to display under buttons using W3 Sidebar and w3-bar-item w3-button?
So far I have this: 到目前为止,我有这个:
<div class="w3-sidebar w3-bar-block w3-indigo w3-xxlarge" style="width:70px">
<a href="#" class="w3-bar-item w3-button"><i class="fa fa-user-circle"></i></a>
<a href="#" class="w3-bar-item w3-button"><i class="fa fa-id-card-o"></i></a>
<a href="#" class="w3-bar-item w3-button"><i class="fa fa-folder-open"></i></a>
</div>
If I enter text into the a tag, the text ends up looking jumbled and doesn't go under the button the way I want it to. 如果我在a标签中输入文本,则文本最终看起来会变得乱七八糟,不会像我想要的那样出现在按钮下方。 How can I fix this? 我怎样才能解决这个问题?
I made a codepen that should match what you are attempting to do : 我制作了一个代码笔 ,它应该与您要尝试执行的操作匹配:
Here is the css : 这是CSS:
.w3-sidebar {
width: auto;
}
.w3-bar-block .w3-bar-item {
/* Overrides default rule */
text-align: center;
}
.sidebar-icon-label {
display: block;
font-size: 10px;
}
You'll see that I removed the inline style of your w3-sidebar, and set it to "auto" instead, which means it will have the size of its content. 您会看到我删除了w3-sidebar的内联样式,并将其设置为“ auto”,这意味着它将具有其内容的大小。
I created a new class for your icon labels, and overrode a native w3 rule to center everything. 我为您的图标标签创建了一个新类,并覆盖了原生的w3规则以使所有内容居中。
Update your code Like this 像这样更新代码
<style>
i{ width:20px;
height:20px;
display:inline-block; }
a{ float:left; width:100%; text-align:center; }
span{ float:left; width:100%; text-align:center; }
</style>
<div class="w3-sidebar w3-bar-block w3-indigo w3-xxlarge"
style="width:70px">
<a href="#" class="w3-bar-item w3-button"><i class="fa fa-user-circle"></i><span>Text 1</span></a>
<a href="#" class="w3-bar-item w3-button"><i class="fa fa-id-card-o"></i><span>Text 1</span></a>
<a href="#" class="w3-bar-item w3-button"><i class="fa fa-folder-open"></i><span>Text 1</span></a>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.