如何在div中居中<i>标签

时间:2017-08-27 04:52:22

标签: html css twitter-bootstrap-3

我想使用i标签将fa放在div上,但我对如何做到这一点毫无头绪。有帮助吗?

我在这里有点新鲜。

由于

示例html:

 remove(i) {
  job.state = job.state === 'in' ? 'out' : 'in';
  this.jobsList.splice(i , 1);
 }

2 个答案:

答案 0 :(得分:2)

text-align:center;设置为父div #lock-cirle,就像这样

&#13;
&#13;
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
    #lock-cirle {
        border: solid 2px #9f070a;
        border-radius: 100%;
        width: 100px;
        height: 100px;
        margin: 0px auto;
        margin-top: 5%;
        margin-bottom: 5%;
        text-align:center;
    }

    #lock-icon{
        font-size: 50px;
        color: #9f070a;
        margin: 27%;
    }
</style>

</head>
<body>
<div class="col-xs-12 col-sm-12 col-md-8 col-md-offset-2 text-center">
    <div id="lock-cirle"  style="background-color: yellow;">
        <i class="fa fa-lock" id="lock-icon" style="background-color: green;"></i>
    </div>
</div>

</body>
</html>
&#13;
&#13;
&#13;

默认情况下,Cuz <I>元素是内联的,text-align CSS属性描述了内联内容的对齐方式

https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements

https://developer.mozilla.org/en-US/docs/Web/CSS/text-align

答案 1 :(得分:1)

Option Explicit
Option Compare Text

Dim fRD As Long, i As Long, fSR As Long, j As Long
Dim pID As String
Dim IE As SHDocVw.InternetExplorer
Dim Doc As MSHTML.HTMLDocument
Dim urL As String
Dim fnd As Boolean

Sub genOP()

With RD

    fRD = .Range("A" & .Rows.Count).End(xlUp).Row
    Set IE = New SHDocVw.InternetExplorer
    urL = "http://eringcapture.jccal.org/caportal/CAPortal_MainPage.aspx"

    For i = 2 To 2

        fSR = SR.Range("A" & SR.Rows.Count).End(xlUp).Row + 1
        pID = Trim(Format(.Range("A" & i).Value, "0"))    ' get PID

        If Len(pID) < 8 Then GoTo nextRow

        IE.Visible = True
        IE.navigate urL

        Call WaitForIE
        Set Doc = IE.document
        Doc.getElementById("Iframe1").contentDocument.getElementById("RealSearchLink").Click
        Call WaitForIE
        Doc.getElementById("Iframe1").contentDocument.getElementById("SearchByParcel").Checked = True

        'SearchByTB
        'Delete the first 2 digits from the excel data (parcel ID), e.g. 22002240080330000000 (instead of 0122002240080330000000)
        'pID = Right(pID, Len(pID) - 2)

        Doc.getElementById("Iframe1").contentDocument.getElementById("SearchText").Value = pID  'Put id in text box
        Doc.getElementById("Iframe1").contentDocument.getElementById("Search").Click  'search button

        Call WaitForIE

        fnd = False

        If Trim(Doc.getElementById("Iframe1").contentDocument.getElementById("TotalRecFound").innerText) = "No Records Found." Then
            For j = 1 To 6

                pID = Left(pID, Len(pID) - 1)

                Doc.getElementById("Iframe1").contentDocument.getElementById("SearchText").Value = pID  'Put id in text box
                Doc.getElementById("Iframe1").contentDocument.getElementById("Search").Click  'search button
                Call WaitForIE

                If Trim(Doc.getElementById("Iframe1").contentDocument.getElementById("TotalRecFound").innerText) <> "No Records Found." Then
                    'Result Found

                    Stop
                    fnd = True
                    Exit For
                End If
            Next j

        Else
            'Result Found

            Stop
            fnd = True
        End If

        If Not fnd Then
            SR.Range("A" & fSR) = "No Records Found"
        End If


nextRow:
    Next i

    IE.Quit
    Set IE = Nothing

End With

MsgBox "Process Completed"

End Sub



Sub WaitForIE()
While IE.Busy Or IE.readyState <> READYSTATE_COMPLETE
    DoEvents
Wend
Application.Wait Now + TimeValue("00:00:05")
End Sub

如上所述纠正你的#lock-icon CSS,因为你想把fa放在div中。