Bra*_*lot 7 html css font-awesome
我正在text-align: right我的 CSS 中尝试,但 text-align 由于某种原因没有移动它。我希望网站标题左对齐,图标右对齐在同一行。这就是我正在尝试的。
HTML
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<div class="top-container">
<h2>Website Title</h2>
<i class="fas fa-bars"></i>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
body {
margin: 0;
}
.top-container {
padding: 20px;
margin: 0;
width: 100%;
color: rgb(255, 255, 255);
background-color: rgba(0, 0, 0, 0.75);
font-size: 2em;
font-weight: bold;
}
.top-container i {
color: red;
display: inline-block;
text-align: right;
}
.top-container h2 {
display: inline-block;
}
h2 {
margin-top: 10px;
}
Run Code Online (Sandbox Code Playgroud)
text-align将对齐 您将其分配给的元素内的文本,这不会在这样的inline-block元素中执行任何操作(因为它与其内容一样宽)。使用float: right;代替text-align: right
https://jsfiddle.net/s4a9sct9/1/
| 归档时间: |
|
| 查看次数: |
19691 次 |
| 最近记录: |