简体   繁体   English

Font Awesome 图标不会移动

[英]Font Awesome Icon won't move

So I'm having a bit of an issue with the placement of my reply icon from font awesome.所以我在放置来自 font awesome 的回复图标时遇到了一些问题。 I've been trying to place it next to my heart icon but to avail.我一直试图将它放在我的心形图标旁边,但没有用。 It's just sitting in the corner of my div and I've tried to use ways to move it but vertical-align: middle and other techniques I've read on other post don't work in my situation.它只是坐在我的 div 的角落里,我尝试使用移动它的方法,但我在其他帖子中阅读的vertical-align: middle和其他技术在我的情况下不起作用。

Here how the div looks like:这里 div 的样子:

<div class="bubble sender first animate-bottom">
    <li class = "display" style = "color = white"> tkjfjk fjkg gfkjgdj gjkd reyk gklfg kgldg gfdklgd gkdlgd way &nbsp; &nbsp;
        <i class="fas fa-heart liked" aria-hidden="true"></i> <sub>6</sub>&nbsp; &nbsp; &nbsp; &nbsp;
        <i class="fa fa-reply reply" aria-hidden="true"></i>
    </li>
    <br>
    <span>

Logically, it should be in the correct position but that is indeed not the case.从逻辑上讲,它应该处于正确的位置,但事实并非如此。 Any help would be appreciated.任何帮助,将不胜感激。

JS Fiddle Here: https://jsfiddle.net/eam6yq28/ JS小提琴在这里: https : //jsfiddle.net/eam6yq28/

Whenever you want to make css changes to font-awesome icons try to change in :before selector.每当您想对字体真棒图标进行 css 更改时,请尝试在:before选择器中进行更改。

In your case add below code to your css file在您的情况下,将以下代码添加到您的 css 文件中

.fa-mail-reply:before, .fa-reply:before {
    position: absolute;
    bottom: 0;
    right: 85px;
}
li {
    list-style-type: none;
    position: relative;
}

Here is th js-fiddle: https://jsfiddle.net/tua85Lrc/1/这是 js-fiddle: https : //jsfiddle.net/tua85Lrc/1/

Your html structure is not semantic but If you just need to place reply icon after heart icon, then just remove below css code from your css file and ignore blank spaces.您的 html 结构不是语义化的,但是如果您只需要在心脏图标之后放置回复图标,那么只需从您的 css 文件中删除以下 css 代码并忽略空格。

.fa{
    box-sizing: border-box;
    padding: 10px;
    width: 42.5px;
    height: 42.5px;
    position: absolute;
    top: 0;
    right: 0;
    border-radius: 50%;
    color: #07051a;
    text-align: center;
    font-size: 1.2em;
    transition: all 1s;
}

 @import url('https://fonts.googleapis.com/css?family=Encode+Sans+Semi+Condensed:700&display=swap'); #title { font-family: 'Encode Sans Semi Condensed', sans-serif; font-size: 85px; color: #cc5500; } #top, #main{ text-align: center; } ul { font-family: 'Encode Sans Semi Condensed', sans-serif; list-style-type: none; color: white; } li { list-style-type: none; } body { background-color: black; /* may have to get rid of this, if any problems arise */ overflow-x: hidden; } form{ position: relative; top: 50%; left: 50%; transform: translate(-50%,-50%); transition: all 1s; width: 50px; height: 50px; background: white; box-sizing: border-box; border-radius: 25px; border: 4px solid white; padding: 5px; } #changelater{ position: absolute; top: 0; left: 0; width: 100%;; height: 42.5px; line-height: 30px; outline: 0; border: 0; display: none; font-size: 1em; border-radius: 20px; padding: 0 20px; } form:hover{ width: 350px; cursor: pointer; } form:hover #changelater{ display: block; } form:hover .fa{ background: #07051a; color: white; } ::placeholder, input[type="search"], input[type ="text"] { font-family: 'Encode Sans Semi Condensed', sans-serif; } footer { font-family: 'Encode Sans Semi Condensed', sans-serif; font-size: 12px; color: white; text-align: center; } html { font-family: 'Encode Sans Semi Condensed', sans-serif; } .discussion { max-width: 600px; margin: 0 auto; display: flex; flex-flow: column; } .discussion > .bubble { border-radius: 1em; padding: 0.25em 0.75em; margin: 0.0625em; max-width: 50%; } .discussion > .bubble.sender { align-self: flex-start; background-color: #cc5500; color: #fff; } .discussion > .bubble.recipient { align-self: flex-end; background-color: #efefef; } .discussion > .bubble.sender.first { border-bottom-left-radius: 0.1em; } .discussion > .bubble.sender.last { border-top-left-radius: 0.1em; } .discussion > .bubble.sender.middle { border-bottom-left-radius: 0.1em; border-top-left-radius: 0.1em; } .discussion > .bubble.recipient.first { border-bottom-right-radius: 0.1em; } .discussion > .bubble.recipient.last { border-top-right-radius: 0.1em; } .discussion > .bubble.recipient.middle { border-bottom-right-radius: 0.1em; border-top-right-radius: 0.1em; } .clicked { color: red; display: block; } .scroll { height: 500px; width: 1000px; overflow-x: hidden; overflow-y: auto; } span { font-size: 8px; } #style-3::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); background-color: black; box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.1); } #style-3::-webkit-scrollbar { width: 6px; background-color: #F5F5F5; } #style-3::-webkit-scrollbar-thumb { background-color: white; } .animate-bottom { position: relative; -webkit-animation-name: animatebottom; -webkit-animation-duration: 500ms; animation-name: animatebottom; animation-duration: 500ms } @-webkit-keyframes animatebottom { from { bottom:-100px; opacity:0 } to { bottom:0px; opacity:1 } } @keyframes animatebottom { from{ bottom:-100px; opacity:0 } to{ bottom:0; opacity:1 } } .pages { height: 100%; margin: 0; padding: 0; width: 100%; display: none; } .page { height: 100%; position: absolute; width: 100%; } /* Login Page */ .login.page { background-color: #000; } .login.page .form { height: 100px; margin-top: -100px; position: absolute; text-align: center; top: 50%; width: 100%; } .login.page .form .usernameInput { background-color: transparent; border: none; border-bottom: 2px solid #fff; outline: none; padding-bottom: 15px; text-align: center; width: 400px; } .login.page .title { font-size: 200%; } .login.page .usernameInput { font-size: 100%; } .login.page .title, .login.page .usernameInput { color: #fff; font-weight: 100; } /* Media Query */ @media only screen and (max-width: 500px) { .formobile { overflow-x: hidden; } #title { font-size: 45px; } .discussion { padding-left: 5px; display: block; } section { text-align: center; } .discussion > .bubble { margin: 1em; max-height: 80px; max-width: 50%; } }
 <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <section class="discussion scroll scrollbar " id="style-3"> <div class="bubble sender first animate-bottom"> <li class = "display" style = "color = white"> tkjfjk fjkg gfkjgdj gjkd reyk gklfg kgldg gfdklgd gkdlgd way &nbsp; &nbsp; <i class="fas fa-heart liked" aria-hidden="true"></i> <sub>6</sub>&nbsp; &nbsp; &nbsp; &nbsp; <i class="fa fa-reply reply" aria-hidden="true"></i> </li> <br> <span>Sent </span> </div> </section>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM