【问题标题】:Font Awesome Icon won't move字体真棒图标不会移动
【发布时间】:2020-04-21 10:18:29
【问题描述】:

所以我在字体真棒中放置回复图标时遇到了一些问题。我一直试图把它放在我的心形图标旁边,但没有用。它就在我的 div 的一角,我尝试使用方法来移动它,但 vertical-align: middle 和我在其他帖子中阅读的其他技术在我的情况下不起作用。

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>

从逻辑上讲,它应该在正确的位置,但事实并非如此。任何帮助将不胜感激。

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

【问题讨论】:

  • 你为什么有&amp;nbsp;?使用边距来推动事情
  • @epascarello 边距不固定回复按钮的位置。正如您在小提琴中看到的那样,它仍然在拐角处。
  • 绝对位置....

标签: jquery html css node.js ejs


【解决方案1】:

每当您想对字体真棒图标进行 css 更改时,请尝试在 :before 选择器中进行更改。

在您的情况下,将以下代码添加到您的 css 文件中

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

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

【讨论】:

    【解决方案2】:

    您的 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>

    【讨论】:

    • 就是这样!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 2014-01-16
    • 2018-02-16
    • 2020-08-11
    相关资源
    最近更新 更多